handle reset confirmation page
This commit is contained in:
@@ -33,8 +33,8 @@ const isFunction = (functionToCheck) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const requireAuth = (nextState, replace, next) => {
|
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)
|
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('/ride') > -1 && replace.params.ride_uuid !== undefined && replace.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();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,33 @@ import React from 'react';
|
|||||||
import APPCONFIG from 'constants/Config';
|
import APPCONFIG from 'constants/Config';
|
||||||
import TextField from 'material-ui/TextField';
|
import TextField from 'material-ui/TextField';
|
||||||
import QueueAnim from 'rc-queue-anim';
|
import QueueAnim from 'rc-queue-anim';
|
||||||
|
import RaisedButton from 'material-ui/RaisedButton';
|
||||||
|
import Instance from '../../../components/Connection';
|
||||||
|
|
||||||
class ForgotPassowrd extends React.Component {
|
class ForgotPassowrd extends React.Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.state = {
|
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() {
|
render() {
|
||||||
@@ -24,6 +44,7 @@ class ForgotPassowrd extends React.Component {
|
|||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<TextField
|
<TextField
|
||||||
floatingLabelText="Email"
|
floatingLabelText="Email"
|
||||||
|
onChange={this.handleEmail}
|
||||||
type="email"
|
type="email"
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
@@ -36,7 +57,12 @@ class ForgotPassowrd extends React.Component {
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div className="card-action no-border text-right">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,12 +2,17 @@ import React from 'react';
|
|||||||
import TextField from 'material-ui/TextField';
|
import TextField from 'material-ui/TextField';
|
||||||
import QueueAnim from 'rc-queue-anim';
|
import QueueAnim from 'rc-queue-anim';
|
||||||
import RaisedButton from 'material-ui/RaisedButton';
|
import RaisedButton from 'material-ui/RaisedButton';
|
||||||
|
import Instance from '../../../components/Connection';
|
||||||
|
|
||||||
class ResetPassowrd extends React.Component {
|
class ResetPassowrd extends React.Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.state = {
|
this.state = {
|
||||||
validated:false,
|
validated:false,
|
||||||
|
token:'',
|
||||||
|
pass:'',
|
||||||
|
passConfirmation:'',
|
||||||
|
password_validated:false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.buttonValidated = this.buttonValidated.bind(this);
|
this.buttonValidated = this.buttonValidated.bind(this);
|
||||||
@@ -34,41 +39,38 @@ class ResetPassowrd extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
clickEvent = (event) => {
|
clickEvent = (event) => {
|
||||||
location.href = '/#/login';
|
|
||||||
/*
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const state = this;
|
const state = this;
|
||||||
|
|
||||||
let user = {
|
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,
|
"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');
|
localStorage.removeItem('loggedUser');
|
||||||
location.href = '/#/login';
|
location.href = '/#/login';
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
if (err.response.status === 422) {
|
console.log(err);
|
||||||
//Unprocessable Entity (validation failed)
|
});
|
||||||
state.setState(Object.assign(state.state, {
|
}
|
||||||
showValidationErrors: true,
|
|
||||||
validationErrors: err.response.data.data
|
componentWillMount(){
|
||||||
}));
|
let urlParts = location.href.split('/');
|
||||||
} else {
|
let token = urlParts[urlParts.length - 1];
|
||||||
alert('Error to log in: ' + err.message);
|
if (token.length < 1) {
|
||||||
}
|
token = urlParts[urlParts.length - 2]
|
||||||
console.error(err);
|
}
|
||||||
|
|
||||||
|
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 = {
|
module.exports = {
|
||||||
path: 'reset-password',
|
path: 'reset-password/:token',
|
||||||
getComponent(nextState, cb) {
|
getComponent(nextState, cb) {
|
||||||
require.ensure([], (require) => {
|
require.ensure([], (require) => {
|
||||||
cb(null, require('./components/ResetPassword'));
|
cb(null, require('./components/ResetPassword'));
|
||||||
|
|||||||
Reference in New Issue
Block a user