mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-28 07:50:32 +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) {
|
resolve(context, payload = {}) {
|
||||||
context.run('forgotPassword', {login: this.getLogin(context)})
|
context.run('forgotPassword', {login: payload.email || this.getLogin(context)})
|
||||||
.then(() => context.setState(new RecoverPasswordState()));
|
.then(() => context.setState(new RecoverPasswordState()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,25 @@ describe('ForgotPasswordState', () => {
|
|||||||
state.resolve(context, {});
|
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', () => {
|
it('should call forgotPassword with username', () => {
|
||||||
const expectedLogin = 'foobar';
|
const expectedLogin = 'foobar';
|
||||||
context.getState.returns({
|
context.getState.returns({
|
||||||
|
Loading…
Reference in New Issue
Block a user