mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-27 23:40:28 +05:30
#192: respect user-entered email in forgotPassword state
This commit is contained in:
parent
fdd56bc886
commit
d1a1b2085b
@ -18,8 +18,8 @@ export default class ForgotPasswordState extends AbstractState {
|
||||
}
|
||||
}
|
||||
|
||||
resolve(context) {
|
||||
context.run('forgotPassword', {login: this.getLogin(context)})
|
||||
resolve(context, payload = {}) {
|
||||
context.run('forgotPassword', {login: payload.email || this.getLogin(context)})
|
||||
.then(() => context.setState(new RecoverPasswordState()));
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,25 @@ describe('ForgotPasswordState', () => {
|
||||
state.resolve(context, {});
|
||||
});
|
||||
|
||||
it('should call forgotPassword with email from payload if any', () => {
|
||||
const expectedLogin = 'foo@bar.com';
|
||||
context.getState.returns({
|
||||
user: {
|
||||
email: 'should.not@be.used'
|
||||
}
|
||||
});
|
||||
|
||||
expectRun(
|
||||
mock,
|
||||
'forgotPassword',
|
||||
sinon.match({
|
||||
login: expectedLogin
|
||||
})
|
||||
).returns({then() {}});
|
||||
|
||||
state.resolve(context, {email: expectedLogin});
|
||||
});
|
||||
|
||||
it('should call forgotPassword with username', () => {
|
||||
const expectedLogin = 'foobar';
|
||||
context.getState.returns({
|
||||
|
Loading…
Reference in New Issue
Block a user