mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-30 02:32:58 +05:30
#389: do not allow return to profile during re-login (temporary solution)
This commit is contained in:
parent
9f926e42bc
commit
64e9056730
@ -7,6 +7,7 @@ import loader from 'services/loader';
|
|||||||
import history from 'services/history';
|
import history from 'services/history';
|
||||||
import { updateUser, acceptRules as userAcceptRules } from 'components/user/actions';
|
import { updateUser, acceptRules as userAcceptRules } from 'components/user/actions';
|
||||||
import { authenticate, logoutAll } from 'components/accounts/actions';
|
import { authenticate, logoutAll } from 'components/accounts/actions';
|
||||||
|
import { getActiveAccount } from 'components/accounts/reducer';
|
||||||
import authentication from 'services/api/authentication';
|
import authentication from 'services/api/authentication';
|
||||||
import oauth from 'services/api/oauth';
|
import oauth from 'services/api/oauth';
|
||||||
import signup from 'services/api/signup';
|
import signup from 'services/api/signup';
|
||||||
@ -436,9 +437,20 @@ export function resetOAuth() {
|
|||||||
* @return {function}
|
* @return {function}
|
||||||
*/
|
*/
|
||||||
export function resetAuth() {
|
export function resetAuth() {
|
||||||
return (dispatch: (Function | Object) => void) => {
|
return (dispatch: (Function | Object) => void, getSate: () => Object): Promise<void> => {
|
||||||
dispatch(setLogin(null));
|
dispatch(setLogin(null));
|
||||||
dispatch(resetOAuth());
|
dispatch(resetOAuth());
|
||||||
|
// ensure current account is valid
|
||||||
|
const activeAccount = getActiveAccount(getSate());
|
||||||
|
|
||||||
|
if (activeAccount) {
|
||||||
|
return Promise.resolve(dispatch(authenticate(activeAccount)))
|
||||||
|
.catch(() => {
|
||||||
|
// its okay. user will be redirected to an appropriate place
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,21 @@ describe('when user\'s token and refreshToken are invalid', () => {
|
|||||||
cy.contains('account preferences');
|
cy.contains('account preferences');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not allow to return to profile using toolbar', () => {
|
||||||
|
cy.visit('/');
|
||||||
|
|
||||||
|
cy.url().should('include', '/password');
|
||||||
|
|
||||||
|
cy
|
||||||
|
.get('[data-e2e-toolbar] a')
|
||||||
|
.contains('Ely.by')
|
||||||
|
.click();
|
||||||
|
|
||||||
|
// TODO: currently we can not skip redirect to /, but we will in future
|
||||||
|
cy.location('pathname', { timeout: 15000 }).should('eq', '/');
|
||||||
|
cy.url({ timeout: 15000 }).should('include', '/password');
|
||||||
|
});
|
||||||
|
|
||||||
it('should allow select account', () => {
|
it('should allow select account', () => {
|
||||||
// TODO: need a way to get valid token for one of the accounts
|
// TODO: need a way to get valid token for one of the accounts
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
|
Loading…
Reference in New Issue
Block a user