#245: disable account switcher after user logged to new account during oauth (ignore prompt=slect_account)

This commit is contained in:
SleepWalker 2017-01-29 14:12:08 +02:00
parent c33f13e49a
commit a4fd1314c2
2 changed files with 10 additions and 20 deletions

View File

@ -19,12 +19,16 @@ export default class PasswordState extends AbstractState {
resolve(context, {password, rememberMe}) { resolve(context, {password, rememberMe}) {
const {auth: {login}} = context.getState(); const {auth: {login}} = context.getState();
context.run('login', { return context.run('login', {
password, password,
rememberMe, rememberMe,
login login
}) })
.then(() => context.setState(new CompleteState())) .then(() => {
context.run('setAccountSwitcher', false);
context.setState(new CompleteState());
})
.catch((err = {}) => err.errors || logger.warn(err)); .catch((err = {}) => err.errors || logger.warn(err));
} }

View File

@ -1,3 +1,4 @@
import expect from 'unexpected';
import sinon from 'sinon'; import sinon from 'sinon';
import PasswordState from 'services/authFlow/PasswordState'; import PasswordState from 'services/authFlow/PasswordState';
@ -60,6 +61,7 @@ describe('PasswordState', () => {
} }
}); });
expectRun(mock, 'setAccountSwitcher', false);
expectRun( expectRun(
mock, mock,
'login', 'login',
@ -69,27 +71,11 @@ describe('PasswordState', () => {
rememberMe: expectedRememberMe, rememberMe: expectedRememberMe,
}) })
).returns(Promise.resolve()); ).returns(Promise.resolve());
state.resolve(context, {password: expectedPassword, rememberMe: expectedRememberMe});
});
it('should transition to complete state on successfull login', () => {
const promise = Promise.resolve();
const expectedLogin = 'login';
const expectedPassword = 'password';
context.getState.returns({
auth: {
login: expectedLogin
}
});
mock.expects('run').returns(promise);
expectState(mock, CompleteState); expectState(mock, CompleteState);
state.resolve(context, {password: expectedPassword}); const payload = {password: expectedPassword, rememberMe: expectedRememberMe};
return promise; return expect(state.resolve(context, payload), 'to be fulfilled');
}); });
}); });