mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-02-17 07:48:16 +05:30
Allow escape from activation step back to login page
This commit is contained in:
parent
5849d1f169
commit
b1774d8354
@ -92,7 +92,7 @@ export function login({
|
|||||||
if (resp.errors.password === PASSWORD_REQUIRED) {
|
if (resp.errors.password === PASSWORD_REQUIRED) {
|
||||||
return dispatch(setLogin(login));
|
return dispatch(setLogin(login));
|
||||||
} else if (resp.errors.login === ACTIVATION_REQUIRED) {
|
} else if (resp.errors.login === ACTIVATION_REQUIRED) {
|
||||||
return dispatch(needActivation());
|
return dispatch(needActivation({ login }));
|
||||||
} else if (resp.errors.totp === TOTP_REQUIRED) {
|
} else if (resp.errors.totp === TOTP_REQUIRED) {
|
||||||
return dispatch(
|
return dispatch(
|
||||||
requestTotp({
|
requestTotp({
|
||||||
@ -174,14 +174,7 @@ export function register({
|
|||||||
captcha,
|
captcha,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
dispatch(
|
dispatch(needActivation({ login: email || username }));
|
||||||
updateUser({
|
|
||||||
username,
|
|
||||||
email,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
dispatch(needActivation());
|
|
||||||
|
|
||||||
browserHistory.push('/activation');
|
browserHistory.push('/activation');
|
||||||
})
|
})
|
||||||
@ -232,8 +225,6 @@ function setCredentials(payload: Credentials | null): SetCredentialsAction {
|
|||||||
/**
|
/**
|
||||||
* Sets login in credentials state
|
* Sets login in credentials state
|
||||||
* Resets the state, when `null` is passed
|
* Resets the state, when `null` is passed
|
||||||
*
|
|
||||||
* @param login
|
|
||||||
*/
|
*/
|
||||||
export function setLogin(login: string | null): SetCredentialsAction {
|
export function setLogin(login: string | null): SetCredentialsAction {
|
||||||
return setCredentials(login ? { login } : null);
|
return setCredentials(login ? { login } : null);
|
||||||
@ -532,11 +523,11 @@ export function resetOAuth(): AppAction {
|
|||||||
* Resets all temporary state related to auth
|
* Resets all temporary state related to auth
|
||||||
*/
|
*/
|
||||||
export function resetAuth(): AppAction {
|
export function resetAuth(): AppAction {
|
||||||
return (dispatch, getSate): Promise<void> => {
|
return (dispatch, getState): Promise<void> => {
|
||||||
dispatch(setLogin(null));
|
dispatch(setLogin(null));
|
||||||
dispatch(resetOAuth());
|
dispatch(resetOAuth());
|
||||||
// ensure current account is valid
|
// ensure current account is valid
|
||||||
const activeAccount = getActiveAccount(getSate());
|
const activeAccount = getActiveAccount(getState());
|
||||||
|
|
||||||
if (activeAccount) {
|
if (activeAccount) {
|
||||||
return Promise.resolve(dispatch(authenticate(activeAccount)))
|
return Promise.resolve(dispatch(authenticate(activeAccount)))
|
||||||
@ -610,10 +601,10 @@ function wrapInLoader<T>(fn: AppAction<Promise<T>>): AppAction<Promise<T>> {
|
|||||||
|
|
||||||
export type LoadingAction = SetLoadingAction;
|
export type LoadingAction = SetLoadingAction;
|
||||||
|
|
||||||
function needActivation() {
|
function needActivation({ login }: { login: string }) {
|
||||||
return updateUser({
|
return setCredentials({
|
||||||
isActive: false,
|
login,
|
||||||
isGuest: false,
|
isActivationRequired: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ export interface Credentials {
|
|||||||
returnUrl?: string;
|
returnUrl?: string;
|
||||||
isRelogin?: boolean;
|
isRelogin?: boolean;
|
||||||
isTotpRequired?: boolean;
|
isTotpRequired?: boolean;
|
||||||
|
isActivationRequired?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Error = Record<
|
type Error = Record<
|
||||||
|
@ -20,7 +20,6 @@ storiesOf('Components/Profile', module).add('Profile', () => (
|
|||||||
username: 'ErickSkrauch',
|
username: 'ErickSkrauch',
|
||||||
email: 'erickskrauch@ely.by',
|
email: 'erickskrauch@ely.by',
|
||||||
hasMojangUsernameCollision: true,
|
hasMojangUsernameCollision: true,
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
isDeleted: false,
|
isDeleted: false,
|
||||||
isOtpEnabled: true,
|
isOtpEnabled: true,
|
||||||
|
@ -9,7 +9,6 @@ export interface User {
|
|||||||
avatar: string;
|
avatar: string;
|
||||||
lang: string;
|
lang: string;
|
||||||
isGuest: boolean;
|
isGuest: boolean;
|
||||||
isActive: boolean;
|
|
||||||
isDeleted: boolean;
|
isDeleted: boolean;
|
||||||
isOtpEnabled: boolean;
|
isOtpEnabled: boolean;
|
||||||
passwordChangedAt: number;
|
passwordChangedAt: number;
|
||||||
@ -31,7 +30,6 @@ const defaults: State = {
|
|||||||
maskedEmail: '',
|
maskedEmail: '',
|
||||||
avatar: '',
|
avatar: '',
|
||||||
lang: '',
|
lang: '',
|
||||||
isActive: false,
|
|
||||||
isDeleted: false,
|
isDeleted: false,
|
||||||
isOtpEnabled: false,
|
isOtpEnabled: false,
|
||||||
shouldAcceptRules: false, // whether user need to review updated rules
|
shouldAcceptRules: false, // whether user need to review updated rules
|
||||||
|
@ -20,7 +20,7 @@ export function register({
|
|||||||
rulesAgreement = false,
|
rulesAgreement = false,
|
||||||
lang = '',
|
lang = '',
|
||||||
captcha = '',
|
captcha = '',
|
||||||
}: RegisterParams): Promise<Resp<void>> {
|
}: RegisterParams): Promise<Resp<{ success: boolean }>> {
|
||||||
return request.post(
|
return request.post(
|
||||||
'/api/signup',
|
'/api/signup',
|
||||||
{ email, username, password, rePassword, rulesAgreement, lang, captcha },
|
{ email, username, password, rePassword, rulesAgreement, lang, captcha },
|
||||||
|
@ -95,10 +95,10 @@ describe('AuthFlow.functional', () => {
|
|||||||
Object.assign(state, {
|
Object.assign(state, {
|
||||||
user: {
|
user: {
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
isActive: true,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 123,
|
clientId: 123,
|
||||||
prompt: [],
|
prompt: [],
|
||||||
|
@ -33,10 +33,11 @@ describe('CompleteState', () => {
|
|||||||
it('should navigate to / for authenticated', () => {
|
it('should navigate to / for authenticated', () => {
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {},
|
auth: {
|
||||||
|
credentials: {},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expectNavigate(mock, '/');
|
expectNavigate(mock, '/');
|
||||||
@ -49,7 +50,9 @@ describe('CompleteState', () => {
|
|||||||
user: {
|
user: {
|
||||||
isGuest: true,
|
isGuest: true,
|
||||||
},
|
},
|
||||||
auth: {},
|
auth: {
|
||||||
|
credentials: {},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expectState(mock, LoginState);
|
expectState(mock, LoginState);
|
||||||
@ -62,7 +65,11 @@ describe('CompleteState', () => {
|
|||||||
user: {
|
user: {
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {},
|
auth: {
|
||||||
|
credentials: {
|
||||||
|
isActivationRequired: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expectState(mock, ActivationState);
|
expectState(mock, ActivationState);
|
||||||
@ -74,11 +81,12 @@ describe('CompleteState', () => {
|
|||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
isActive: true,
|
|
||||||
shouldAcceptRules: true,
|
shouldAcceptRules: true,
|
||||||
isDeleted: true,
|
isDeleted: true,
|
||||||
},
|
},
|
||||||
auth: {},
|
auth: {
|
||||||
|
credentials: {},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expectNavigate(mock, '/');
|
expectNavigate(mock, '/');
|
||||||
@ -90,10 +98,11 @@ describe('CompleteState', () => {
|
|||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
shouldAcceptRules: true,
|
shouldAcceptRules: true,
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {},
|
auth: {
|
||||||
|
credentials: {},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expectState(mock, AcceptRulesState);
|
expectState(mock, AcceptRulesState);
|
||||||
@ -107,7 +116,11 @@ describe('CompleteState', () => {
|
|||||||
shouldAcceptRules: true,
|
shouldAcceptRules: true,
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {},
|
auth: {
|
||||||
|
credentials: {
|
||||||
|
isActivationRequired: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expectState(mock, ActivationState);
|
expectState(mock, ActivationState);
|
||||||
@ -119,10 +132,10 @@ describe('CompleteState', () => {
|
|||||||
it('should transition to finish state if code is present', () => {
|
it('should transition to finish state if code is present', () => {
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
code: 'XXX',
|
code: 'XXX',
|
||||||
@ -139,10 +152,10 @@ describe('CompleteState', () => {
|
|||||||
it('should transition to permissions state if acceptRequired', () => {
|
it('should transition to permissions state if acceptRequired', () => {
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
acceptRequired: true,
|
acceptRequired: true,
|
||||||
@ -158,10 +171,10 @@ describe('CompleteState', () => {
|
|||||||
it('should transition to permissions state if prompt=consent', () => {
|
it('should transition to permissions state if prompt=consent', () => {
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
prompt: ['consent'],
|
prompt: ['consent'],
|
||||||
@ -179,7 +192,6 @@ describe('CompleteState', () => {
|
|||||||
it('should transition to ChooseAccountState if user has multiple accs and switcher enabled', () => {
|
it('should transition to ChooseAccountState if user has multiple accs and switcher enabled', () => {
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
accounts: {
|
accounts: {
|
||||||
@ -187,6 +199,7 @@ describe('CompleteState', () => {
|
|||||||
active: 1,
|
active: 1,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
isSwitcherEnabled: true,
|
isSwitcherEnabled: true,
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
@ -203,7 +216,6 @@ describe('CompleteState', () => {
|
|||||||
it('should transition to ChooseAccountState if user isDeleted', () => {
|
it('should transition to ChooseAccountState if user isDeleted', () => {
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isDeleted: true,
|
isDeleted: true,
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
@ -213,6 +225,7 @@ describe('CompleteState', () => {
|
|||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
isSwitcherEnabled: true,
|
isSwitcherEnabled: true,
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
prompt: [],
|
prompt: [],
|
||||||
@ -228,7 +241,6 @@ describe('CompleteState', () => {
|
|||||||
it('should NOT transition to ChooseAccountState if user has multiple accs and switcher disabled', () => {
|
it('should NOT transition to ChooseAccountState if user has multiple accs and switcher disabled', () => {
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
accounts: {
|
accounts: {
|
||||||
@ -237,6 +249,7 @@ describe('CompleteState', () => {
|
|||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
isSwitcherEnabled: false,
|
isSwitcherEnabled: false,
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
prompt: [],
|
prompt: [],
|
||||||
@ -252,7 +265,6 @@ describe('CompleteState', () => {
|
|||||||
it('should transition to ChooseAccountState if prompt=select_account and switcher enabled', () => {
|
it('should transition to ChooseAccountState if prompt=select_account and switcher enabled', () => {
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
accounts: {
|
accounts: {
|
||||||
@ -261,6 +273,7 @@ describe('CompleteState', () => {
|
|||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
isSwitcherEnabled: true,
|
isSwitcherEnabled: true,
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
prompt: ['select_account'],
|
prompt: ['select_account'],
|
||||||
@ -276,7 +289,6 @@ describe('CompleteState', () => {
|
|||||||
it('should NOT transition to ChooseAccountState if prompt=select_account and switcher disabled', () => {
|
it('should NOT transition to ChooseAccountState if prompt=select_account and switcher disabled', () => {
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
accounts: {
|
accounts: {
|
||||||
@ -285,6 +297,7 @@ describe('CompleteState', () => {
|
|||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
isSwitcherEnabled: false,
|
isSwitcherEnabled: false,
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
prompt: ['select_account'],
|
prompt: ['select_account'],
|
||||||
@ -304,10 +317,10 @@ describe('CompleteState', () => {
|
|||||||
it('should run oAuthComplete', () => {
|
it('should run oAuthComplete', () => {
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
prompt: [],
|
prompt: [],
|
||||||
@ -325,10 +338,10 @@ describe('CompleteState', () => {
|
|||||||
it('should listen for auth success/failure', () => {
|
it('should listen for auth success/failure', () => {
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
prompt: [],
|
prompt: [],
|
||||||
@ -352,10 +365,10 @@ describe('CompleteState', () => {
|
|||||||
|
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
prompt: [],
|
prompt: [],
|
||||||
@ -381,10 +394,10 @@ describe('CompleteState', () => {
|
|||||||
|
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
prompt: [],
|
prompt: [],
|
||||||
@ -425,7 +438,6 @@ describe('CompleteState', () => {
|
|||||||
|
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
accounts: {
|
accounts: {
|
||||||
@ -433,6 +445,7 @@ describe('CompleteState', () => {
|
|||||||
active: 100,
|
active: 100,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
loginHint: account[field],
|
loginHint: account[field],
|
||||||
@ -463,7 +476,6 @@ describe('CompleteState', () => {
|
|||||||
|
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
accounts: {
|
accounts: {
|
||||||
@ -471,6 +483,7 @@ describe('CompleteState', () => {
|
|||||||
active: account.id,
|
active: account.id,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
loginHint: account.id,
|
loginHint: account.id,
|
||||||
@ -496,7 +509,6 @@ describe('CompleteState', () => {
|
|||||||
|
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
accounts: {
|
accounts: {
|
||||||
@ -504,6 +516,7 @@ describe('CompleteState', () => {
|
|||||||
active: 1,
|
active: 1,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
loginHint: account.id,
|
loginHint: account.id,
|
||||||
@ -542,10 +555,10 @@ describe('CompleteState', () => {
|
|||||||
state = new CompleteState(expected);
|
state = new CompleteState(expected);
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
prompt: [],
|
prompt: [],
|
||||||
@ -567,10 +580,10 @@ describe('CompleteState', () => {
|
|||||||
state = new CompleteState(expected);
|
state = new CompleteState(expected);
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
prompt: [],
|
prompt: [],
|
||||||
@ -593,10 +606,10 @@ describe('CompleteState', () => {
|
|||||||
state = new CompleteState(expected);
|
state = new CompleteState(expected);
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
prompt: [],
|
prompt: [],
|
||||||
@ -620,10 +633,10 @@ describe('CompleteState', () => {
|
|||||||
state = new CompleteState(expected);
|
state = new CompleteState(expected);
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
user: {
|
user: {
|
||||||
isActive: true,
|
|
||||||
isGuest: false,
|
isGuest: false,
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
|
credentials: {},
|
||||||
oauth: {
|
oauth: {
|
||||||
clientId: 'ely.by',
|
clientId: 'ely.by',
|
||||||
prompt: [],
|
prompt: [],
|
||||||
|
@ -26,14 +26,14 @@ export default class CompleteState extends AbstractState {
|
|||||||
|
|
||||||
enter(context: AuthContext): Promise<void> | void {
|
enter(context: AuthContext): Promise<void> | void {
|
||||||
const {
|
const {
|
||||||
auth: { oauth },
|
auth: { credentials, oauth },
|
||||||
user,
|
user,
|
||||||
} = context.getState();
|
} = context.getState();
|
||||||
|
|
||||||
if (user.isGuest) {
|
if (credentials.isActivationRequired) {
|
||||||
context.setState(new LoginState());
|
|
||||||
} else if (!user.isActive) {
|
|
||||||
context.setState(new ActivationState());
|
context.setState(new ActivationState());
|
||||||
|
} else if (user.isGuest) {
|
||||||
|
context.setState(new LoginState());
|
||||||
} else if (user.shouldAcceptRules && !user.isDeleted) {
|
} else if (user.shouldAcceptRules && !user.isDeleted) {
|
||||||
context.setState(new AcceptRulesState());
|
context.setState(new AcceptRulesState());
|
||||||
} else if (oauth && oauth.clientId) {
|
} else if (oauth && oauth.clientId) {
|
||||||
|
@ -70,6 +70,55 @@ describe('Register', () => {
|
|||||||
cy.location('pathname').should('eq', '/');
|
cy.location('pathname').should('eq', '/');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should allow return to login page from activation', () => {
|
||||||
|
const username = `test${Date.now()}`;
|
||||||
|
const email = `${Date.now()}@gmail.com`;
|
||||||
|
const password = String(Date.now());
|
||||||
|
const captchaCode = 'captchaCode';
|
||||||
|
|
||||||
|
cy.server();
|
||||||
|
cy.route({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/api/signup',
|
||||||
|
response: {
|
||||||
|
success: true,
|
||||||
|
},
|
||||||
|
}).as('signup');
|
||||||
|
cy.login({
|
||||||
|
accounts: ['default'],
|
||||||
|
updateState: false,
|
||||||
|
rawApiResp: true,
|
||||||
|
});
|
||||||
|
cy.visit('/');
|
||||||
|
|
||||||
|
cy.findByTestId('toolbar').contains('Join').click();
|
||||||
|
|
||||||
|
cy.location('pathname').should('eq', '/register');
|
||||||
|
|
||||||
|
cy.get('[name=username]').type(username);
|
||||||
|
cy.get('[name=email]').type(email);
|
||||||
|
cy.get('[name=password]').type(password);
|
||||||
|
cy.get('[name=rePassword]').type(password);
|
||||||
|
cy.get('[name=rulesAgreement]').should('not.be.checked');
|
||||||
|
cy.get('[name=rulesAgreement]').parent().click();
|
||||||
|
cy.get('[name=rulesAgreement]').should('be.checked');
|
||||||
|
cy.window().should('have.property', 'e2eCaptchaSetCode');
|
||||||
|
cy.window().then((win) => {
|
||||||
|
// fake captcha response
|
||||||
|
// @ts-ignore
|
||||||
|
win.e2eCaptchaSetCode(captchaCode);
|
||||||
|
});
|
||||||
|
cy.get('[type=submit]').click();
|
||||||
|
|
||||||
|
cy.wait('@signup');
|
||||||
|
|
||||||
|
cy.location('pathname').should('eq', '/activation');
|
||||||
|
|
||||||
|
cy.findByTestId('home-page').click();
|
||||||
|
|
||||||
|
cy.location('pathname').should('eq', '/login');
|
||||||
|
});
|
||||||
|
|
||||||
it('should allow activation', () => {
|
it('should allow activation', () => {
|
||||||
const activationKey = 'activationKey';
|
const activationKey = 'activationKey';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user