2016-11-13 20:17:56 +05:30
|
|
|
import AbstractState from './AbstractState';
|
2020-01-18 02:07:52 +05:30
|
|
|
import { AuthContext } from './AuthFlow';
|
2016-11-13 20:17:56 +05:30
|
|
|
import LoginState from './LoginState';
|
|
|
|
import CompleteState from './CompleteState';
|
|
|
|
|
|
|
|
export default class ChooseAccountState extends AbstractState {
|
2020-01-18 02:07:52 +05:30
|
|
|
enter(context: AuthContext): Promise<void> | void {
|
2019-11-27 14:33:32 +05:30
|
|
|
const { auth } = context.getState();
|
2018-02-18 01:29:35 +05:30
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
if (auth.oauth) {
|
|
|
|
context.navigate('/oauth/choose-account');
|
|
|
|
} else {
|
|
|
|
context.navigate('/choose-account');
|
2016-11-13 20:17:56 +05:30
|
|
|
}
|
2019-11-27 14:33:32 +05:30
|
|
|
}
|
2016-11-13 20:17:56 +05:30
|
|
|
|
2020-01-18 02:07:52 +05:30
|
|
|
resolve(
|
|
|
|
context: AuthContext,
|
|
|
|
payload: Record<string, any>,
|
|
|
|
): Promise<void> | void {
|
2019-11-27 14:33:32 +05:30
|
|
|
if (payload.id) {
|
|
|
|
context.setState(new CompleteState());
|
|
|
|
} else {
|
|
|
|
context.navigate('/login');
|
|
|
|
context.run('setLogin', null);
|
|
|
|
context.setState(new LoginState());
|
2016-11-13 20:17:56 +05:30
|
|
|
}
|
2019-11-27 14:33:32 +05:30
|
|
|
}
|
2016-11-19 17:49:23 +05:30
|
|
|
|
2020-01-18 02:07:52 +05:30
|
|
|
reject(context: AuthContext): void {
|
2019-11-27 14:33:32 +05:30
|
|
|
context.run('logout');
|
|
|
|
}
|
2016-11-13 20:17:56 +05:30
|
|
|
}
|