Compare commits
3 Commits
phone-mask
...
password-r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c922ed596d | ||
|
|
cd30c937f0 | ||
|
|
6c262a03d9 |
@@ -33,8 +33,8 @@ const isFunction = (functionToCheck) => {
|
||||
};
|
||||
|
||||
const requireAuth = (nextState, replace, next) => {
|
||||
if (nextState.location.pathname === '/login' || nextState.location.pathname === '/sign-up' || nextState.location.pathname.toLowerCase() === '/selfregister' || (nextState.location.pathname.indexOf('/ride') > -1 && nextState.params.ride_uuid !== undefined && nextState.params.user_uuid !== undefined)
|
||||
|| (!isFunction(replace) && (replace.location.pathname === '/login' || replace.location.pathname === '/sign-up' || nextState.location.pathname.toLowerCase() === '/selfRegister' || (replace.location.pathname.indexOf('/ride') > -1 && replace.params.ride_uuid !== undefined && replace.params.user_uuid !== undefined)))) {
|
||||
if (nextState.location.pathname === '/login' || nextState.location.pathname === '/sign-up' || nextState.location.pathname.toLowerCase() === '/selfregister' || (nextState.location.pathname.indexOf('/reset-password') > -1 && nextState.params.token !== undefined) || (nextState.location.pathname.indexOf('/ride') > -1 && nextState.params.ride_uuid !== undefined && nextState.params.user_uuid !== undefined)
|
||||
|| (!isFunction(replace) && (replace.location.pathname === '/login' || replace.location.pathname === '/sign-up' || nextState.location.pathname.toLowerCase() === '/selfRegister' || (replace.location.pathname.indexOf('/reset-password') > -1 && replace.params.token !== undefined) || (replace.location.pathname.indexOf('/ride') > -1 && replace.params.ride_uuid !== undefined && replace.params.user_uuid !== undefined)))) {
|
||||
next();
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ const rootRoute = {
|
||||
require('./routes/500'),
|
||||
require('./routes/confirmEmail'),
|
||||
require('./routes/forgotPassword'),
|
||||
require('./routes/resetPassword'),
|
||||
require('./routes/lockScreen'),
|
||||
require('./routes/login'),
|
||||
require('./routes/signUp'),
|
||||
|
||||
@@ -2,13 +2,33 @@ import React from 'react';
|
||||
import APPCONFIG from 'constants/Config';
|
||||
import TextField from 'material-ui/TextField';
|
||||
import QueueAnim from 'rc-queue-anim';
|
||||
import RaisedButton from 'material-ui/RaisedButton';
|
||||
import Instance from '../../../components/Connection';
|
||||
|
||||
class ForgotPassowrd extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
brand: APPCONFIG.brand
|
||||
brand: APPCONFIG.brand,
|
||||
email: '',
|
||||
};
|
||||
|
||||
this.handleEmail = this.handleEmail.bind(this);
|
||||
}
|
||||
|
||||
handleEmail = (event) => {
|
||||
this.setState(Object.assign(this.state, { email: event.target.value }));
|
||||
};
|
||||
|
||||
clickEvent = (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
Instance.setToken(null).post('/v1/passwordreset/request/' + this.state.email).then(function (res) {
|
||||
location.href = '/#/confirm-email';
|
||||
}).catch(function (err) {
|
||||
location.href = '/#/confirm-email';
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -24,6 +44,7 @@ class ForgotPassowrd extends React.Component {
|
||||
<div className="form-group">
|
||||
<TextField
|
||||
floatingLabelText="Email"
|
||||
onChange={this.handleEmail}
|
||||
type="email"
|
||||
fullWidth
|
||||
/>
|
||||
@@ -36,7 +57,12 @@ class ForgotPassowrd extends React.Component {
|
||||
</form>
|
||||
</div>
|
||||
<div className="card-action no-border text-right">
|
||||
<a href="/#/confirm-password" className="color-primary">Reset</a>
|
||||
<RaisedButton
|
||||
label="Reset"
|
||||
primary={true}
|
||||
onClick={this.clickEvent}
|
||||
disabled={this.state.email===''}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
132
src/routes/resetPassword/components/ResetPassword.js
Normal file
132
src/routes/resetPassword/components/ResetPassword.js
Normal file
@@ -0,0 +1,132 @@
|
||||
import React from 'react';
|
||||
import TextField from 'material-ui/TextField';
|
||||
import QueueAnim from 'rc-queue-anim';
|
||||
import RaisedButton from 'material-ui/RaisedButton';
|
||||
import Instance from '../../../components/Connection';
|
||||
|
||||
class ResetPassowrd extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
validated:false,
|
||||
token:'',
|
||||
pass:'',
|
||||
passConfirmation:'',
|
||||
password_validated:false,
|
||||
};
|
||||
|
||||
this.buttonValidated = this.buttonValidated.bind(this);
|
||||
this.handlePass = this.handlePass.bind(this);
|
||||
this.handleConfirmationPass = this.handleConfirmationPass.bind(this);
|
||||
this.clickEvent = this.clickEvent.bind(this);
|
||||
}
|
||||
|
||||
buttonValidated = () => {
|
||||
let validated = true;
|
||||
if (!this.state.password_validated || !this.state.pass || this.state.pass === null || this.state.pass === "") validated = false;
|
||||
|
||||
this.setState(Object.assign(this.state, { validated: validated }));
|
||||
}
|
||||
|
||||
handlePass = (event) => {
|
||||
this.setState(Object.assign(this.state, { pass: btoa(event.target.value) }));
|
||||
this.setState(Object.assign(this.state, { password_validated: this.state.pass === this.state.passConfirmation }));
|
||||
};
|
||||
|
||||
handleConfirmationPass = (event) => {
|
||||
this.setState(Object.assign(this.state, { passConfirmation: btoa(event.target.value) }));
|
||||
this.setState(Object.assign(this.state, { password_validated: this.state.pass === this.state.passConfirmation }));
|
||||
};
|
||||
|
||||
clickEvent = (event) => {
|
||||
event.preventDefault();
|
||||
const state = this;
|
||||
|
||||
let user = {
|
||||
"pass": this.state.pass,
|
||||
};
|
||||
|
||||
Instance.setToken(null).post('/v1/passwordreset/complete/' + state.state.token, user).then(function (res) {
|
||||
localStorage.removeItem('loggedUser');
|
||||
location.href = '/#/login';
|
||||
}).catch(function (err) {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
componentWillMount(){
|
||||
let urlParts = location.href.split('/');
|
||||
let token = urlParts[urlParts.length - 1];
|
||||
if (token.length < 1) {
|
||||
token = urlParts[urlParts.length - 2]
|
||||
}
|
||||
|
||||
let state = this;
|
||||
|
||||
|
||||
Instance.setToken(null).post('/v1/passwordreset/open/' + token).then(res=>{
|
||||
state.setState(Object.assign(state.state, {
|
||||
token:token
|
||||
}));
|
||||
}).catch(err=>{
|
||||
location.href = '/#/404';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="body-inner">
|
||||
<div className="card bg-white">
|
||||
<div className="card-content">
|
||||
<section className="logo text-center">
|
||||
<h1><a href="#/">Reset Password</a></h1>
|
||||
</section>
|
||||
<form>
|
||||
<fieldset>
|
||||
<div className="form-group">
|
||||
<TextField
|
||||
floatingLabelText="Choose New Password"
|
||||
type="password"
|
||||
onChange={this.handlePass}
|
||||
onBlur={this.buttonValidated}
|
||||
/>
|
||||
<TextField
|
||||
floatingLabelText="Verify New Password"
|
||||
type="password"
|
||||
onChange={this.handleConfirmationPass}
|
||||
onBlur={this.buttonValidated}
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div className="card-action no-border text-right">
|
||||
<RaisedButton
|
||||
label="Reset"
|
||||
primary={true}
|
||||
onClick={this.clickEvent}
|
||||
disabled={!this.state.validated}
|
||||
/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const Page = () => (
|
||||
<div className="page-forgot">
|
||||
<div className="main-body">
|
||||
<QueueAnim type="bottom" className="ui-animate">
|
||||
<div key="1">
|
||||
<ResetPassowrd />
|
||||
</div>
|
||||
</QueueAnim>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
module.exports = Page;
|
||||
|
||||
8
src/routes/resetPassword/index.js
Normal file
8
src/routes/resetPassword/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
path: 'reset-password/:token',
|
||||
getComponent(nextState, cb) {
|
||||
require.ensure([], (require) => {
|
||||
cb(null, require('./components/ResetPassword'));
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -19,7 +19,6 @@ import Instance from '../../../components/Connection';
|
||||
|
||||
import Checkbox from 'material-ui/Checkbox';
|
||||
|
||||
import InputMask from 'react-input-mask';
|
||||
import ValidationErrorsInfoDialog from '../../../components/Shared/ValidationErrorsInfoDialog';
|
||||
|
||||
class SignUp extends React.Component {
|
||||
@@ -62,15 +61,15 @@ class SignUp extends React.Component {
|
||||
|
||||
componentDidMount = () => { }
|
||||
|
||||
getFormattedPhoneNumber(phone){
|
||||
if(phone && phone.length > 0) {
|
||||
return phone.replace('+1','').replace('(','').replace(')','').replace('-','').replace(' ','').trim()
|
||||
getFormattedPhoneNumber(){
|
||||
if(this.state.phone_number && this.state.phone_number.length > 0) {
|
||||
return this.state.phone_number.replace('+1','').replace('(','').replace(')','').replace('-','').replace(' ','').trim()
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
isPhoneNumberFormatValid() {
|
||||
let formattedNumber = this.getFormattedPhoneNumber(this.state.phone_number);
|
||||
let formattedNumber = this.getFormattedPhoneNumber();
|
||||
return !isNaN(formattedNumber) && (formattedNumber.toString().length === 10);
|
||||
}
|
||||
|
||||
@@ -109,7 +108,7 @@ class SignUp extends React.Component {
|
||||
};
|
||||
|
||||
handlePhone = (event) => {
|
||||
let phone = this.getFormattedPhoneNumber(event.target.value);
|
||||
let phone = event.target.value;
|
||||
if (phone.indexOf("+1") < 0 && phone.length == 10) {
|
||||
phone = "+1" + phone;
|
||||
phone = phone.substring(0, 12);
|
||||
@@ -160,9 +159,6 @@ class SignUp extends React.Component {
|
||||
"pass": this.state.pass,
|
||||
};
|
||||
|
||||
console.log(user);
|
||||
return;
|
||||
|
||||
Instance.setToken(null).post('/v1/selfregister/', user).then(function (res) {
|
||||
localStorage.removeItem('loggedUser');
|
||||
location.href = '/#/login';
|
||||
@@ -249,9 +245,7 @@ class SignUp extends React.Component {
|
||||
type="telephone"
|
||||
onChange={this.handlePhone}
|
||||
onBlur={this.buttonValidated}
|
||||
>
|
||||
<InputMask mask="(999) 999-9999" maskChar={null} value={this.state.phone_number} />
|
||||
</TextField>
|
||||
/>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<TextField
|
||||
|
||||
Reference in New Issue
Block a user