Compare commits
3 Commits
password-r
...
phone-mask
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b4e6cfce2 | ||
|
|
1817ec7ee3 | ||
|
|
942e339f39 |
@@ -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('/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)))) {
|
||||
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)))) {
|
||||
next();
|
||||
}
|
||||
|
||||
@@ -74,7 +74,6 @@ const rootRoute = {
|
||||
require('./routes/500'),
|
||||
require('./routes/confirmEmail'),
|
||||
require('./routes/forgotPassword'),
|
||||
require('./routes/resetPassword'),
|
||||
require('./routes/lockScreen'),
|
||||
require('./routes/login'),
|
||||
require('./routes/signUp'),
|
||||
|
||||
@@ -2,33 +2,13 @@ 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,
|
||||
email: '',
|
||||
brand: APPCONFIG.brand
|
||||
};
|
||||
|
||||
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() {
|
||||
@@ -44,7 +24,6 @@ class ForgotPassowrd extends React.Component {
|
||||
<div className="form-group">
|
||||
<TextField
|
||||
floatingLabelText="Email"
|
||||
onChange={this.handleEmail}
|
||||
type="email"
|
||||
fullWidth
|
||||
/>
|
||||
@@ -57,12 +36,7 @@ class ForgotPassowrd extends React.Component {
|
||||
</form>
|
||||
</div>
|
||||
<div className="card-action no-border text-right">
|
||||
<RaisedButton
|
||||
label="Reset"
|
||||
primary={true}
|
||||
onClick={this.clickEvent}
|
||||
disabled={this.state.email===''}
|
||||
/>
|
||||
<a href="/#/confirm-password" className="color-primary">Reset</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
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;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
module.exports = {
|
||||
path: 'reset-password/:token',
|
||||
getComponent(nextState, cb) {
|
||||
require.ensure([], (require) => {
|
||||
cb(null, require('./components/ResetPassword'));
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -19,6 +19,7 @@ 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 {
|
||||
@@ -61,15 +62,15 @@ class SignUp extends React.Component {
|
||||
|
||||
componentDidMount = () => { }
|
||||
|
||||
getFormattedPhoneNumber(){
|
||||
if(this.state.phone_number && this.state.phone_number.length > 0) {
|
||||
return this.state.phone_number.replace('+1','').replace('(','').replace(')','').replace('-','').replace(' ','').trim()
|
||||
getFormattedPhoneNumber(phone){
|
||||
if(phone && phone.length > 0) {
|
||||
return phone.replace('+1','').replace('(','').replace(')','').replace('-','').replace(' ','').trim()
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
isPhoneNumberFormatValid() {
|
||||
let formattedNumber = this.getFormattedPhoneNumber();
|
||||
let formattedNumber = this.getFormattedPhoneNumber(this.state.phone_number);
|
||||
return !isNaN(formattedNumber) && (formattedNumber.toString().length === 10);
|
||||
}
|
||||
|
||||
@@ -108,7 +109,7 @@ class SignUp extends React.Component {
|
||||
};
|
||||
|
||||
handlePhone = (event) => {
|
||||
let phone = event.target.value;
|
||||
let phone = this.getFormattedPhoneNumber(event.target.value);
|
||||
if (phone.indexOf("+1") < 0 && phone.length == 10) {
|
||||
phone = "+1" + phone;
|
||||
phone = phone.substring(0, 12);
|
||||
@@ -159,6 +160,9 @@ 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';
|
||||
@@ -245,7 +249,9 @@ 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