handle reset confirmation page
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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-email" className="color-primary">Reset</a>
|
||||
<RaisedButton
|
||||
label="Reset"
|
||||
primary={true}
|
||||
onClick={this.clickEvent}
|
||||
disabled={this.state.email===''}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,12 +2,17 @@ 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);
|
||||
@@ -34,41 +39,38 @@ class ResetPassowrd extends React.Component {
|
||||
};
|
||||
|
||||
clickEvent = (event) => {
|
||||
location.href = '/#/login';
|
||||
/*
|
||||
event.preventDefault();
|
||||
const state = this;
|
||||
|
||||
let user = {
|
||||
"provider":
|
||||
{
|
||||
"org_name": this.state.provider_name,
|
||||
"internal_id": this.state.provider_npi
|
||||
},
|
||||
"name": this.state.first + ' ' + this.state.last,
|
||||
"first": this.state.first,
|
||||
"last": this.state.last,
|
||||
"email": this.state.email,
|
||||
"phonenumber": this.state.phone_number,
|
||||
"pass": this.state.pass,
|
||||
};
|
||||
|
||||
Instance.setToken(null).post('/v1/selfregister/', user).then(function (res) {
|
||||
Instance.setToken(null).post('/v1/passworddreset/complete' + state.state.token, user).then(function (res) {
|
||||
localStorage.removeItem('loggedUser');
|
||||
location.href = '/#/login';
|
||||
}).catch(function (err) {
|
||||
if (err.response.status === 422) {
|
||||
//Unprocessable Entity (validation failed)
|
||||
state.setState(Object.assign(state.state, {
|
||||
showValidationErrors: true,
|
||||
validationErrors: err.response.data.data
|
||||
}));
|
||||
} else {
|
||||
alert('Error to log in: ' + err.message);
|
||||
}
|
||||
console.error(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';
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
path: 'reset-password',
|
||||
path: 'reset-password/:token',
|
||||
getComponent(nextState, cb) {
|
||||
require.ensure([], (require) => {
|
||||
cb(null, require('./components/ResetPassword'));
|
||||
|
||||
Reference in New Issue
Block a user