Compare commits

...

3 Commits

Author SHA1 Message Date
GotPPay
c922ed596d fix typo 2018-06-01 14:54:17 +02:00
GotPPay
cd30c937f0 handle reset confirmation page 2018-06-01 12:06:06 +02:00
GotPPay
6c262a03d9 add password reset page 2018-06-01 12:06:06 +02:00
4 changed files with 171 additions and 4 deletions

View File

@@ -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'),

View File

@@ -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>

View 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;

View File

@@ -0,0 +1,8 @@
module.exports = {
path: 'reset-password/:token',
getComponent(nextState, cb) {
require.ensure([], (require) => {
cb(null, require('./components/ResetPassword'));
});
}
};