Auth flow. The next

This commit is contained in:
SleepWalker
2016-03-01 22:36:14 +02:00
parent a317bfd3d4
commit 57f0cf30e6
28 changed files with 438 additions and 243 deletions

View File

@@ -0,0 +1,34 @@
import AbstractState from './AbstractState';
import CompleteState from './CompleteState';
import ForgotPasswordState from './ForgotPasswordState';
export default class PasswordState extends AbstractState {
enter(context) {
const {user} = context.getState();
if (!user.isGuest) {
context.setState(new CompleteState());
} else {
context.navigate('/password');
}
}
resolve(context, {password}) {
const {user} = context.getState();
context.run('login', {
password,
login: user.email || user.username
})
.then(() => context.setState(new CompleteState()));
}
reject(context) {
context.setState(new ForgotPasswordState());
}
goBack(context) {
context.run('logout');
context.setState(new LoginState());
}
}