From 692e9b0ccd0e7dde5b98b5d531822f5b0a3e3616 Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Fri, 21 Apr 2017 08:28:19 +0300 Subject: [PATCH] #330: do not alter payload in ForgotPasswordState. Just pass it through --- .../auth/forgotPassword/ForgotPasswordBody.jsx | 10 +++++----- src/services/authFlow/ForgotPasswordState.js | 6 ++---- tests/services/authFlow/ForgotPasswordState.test.js | 6 +++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/components/auth/forgotPassword/ForgotPasswordBody.jsx b/src/components/auth/forgotPassword/ForgotPasswordBody.jsx index 9d4024c..6f5db0e 100644 --- a/src/components/auth/forgotPassword/ForgotPasswordBody.jsx +++ b/src/components/auth/forgotPassword/ForgotPasswordBody.jsx @@ -18,7 +18,7 @@ export default class ForgotPasswordBody extends BaseAuthBody { isLoginEdit: !this.getLogin() }; - autoFocusField = this.state.isLoginEdit ? 'email' : null; + autoFocusField = this.state.isLoginEdit ? 'login' : null; render() { const login = this.getLogin(); @@ -37,7 +37,7 @@ export default class ForgotPasswordBody extends BaseAuthBody {

- {this.form.focus('email');}, 300); + setTimeout(() => {this.form.focus('login');}, 300); }; } diff --git a/src/services/authFlow/ForgotPasswordState.js b/src/services/authFlow/ForgotPasswordState.js index 001682d..6aa89a4 100644 --- a/src/services/authFlow/ForgotPasswordState.js +++ b/src/services/authFlow/ForgotPasswordState.js @@ -10,11 +10,9 @@ export default class ForgotPasswordState extends AbstractState { } resolve(context, payload = {}) { - const login = payload.email; - - context.run('forgotPassword', {login}) + context.run('forgotPassword', payload) .then(() => { - context.run('setLogin', login); + context.run('setLogin', payload.login); context.setState(new RecoverPasswordState()); }) .catch((err = {}) => diff --git a/tests/services/authFlow/ForgotPasswordState.test.js b/tests/services/authFlow/ForgotPasswordState.test.js index 70d9d23..1e050fa 100644 --- a/tests/services/authFlow/ForgotPasswordState.test.js +++ b/tests/services/authFlow/ForgotPasswordState.test.js @@ -43,7 +43,7 @@ describe('ForgotPasswordState', () => { }) ).returns(Promise.resolve()); - state.resolve(context, {email: expectedLogin}); + state.resolve(context, {login: expectedLogin}); }); it('should transition to recoverPassword state on success', () => { @@ -53,7 +53,7 @@ describe('ForgotPasswordState', () => { mock.expects('run').twice().returns(promise); expectState(mock, RecoverPasswordState); - state.resolve(context, {email: expectedLogin}); + state.resolve(context, {login: expectedLogin}); return promise; }); @@ -66,7 +66,7 @@ describe('ForgotPasswordState', () => { expectState(mock, RecoverPasswordState); mock.expects('run').withArgs('setLogin', expectedLogin); - state.resolve(context, {email: expectedLogin}); + state.resolve(context, {login: expectedLogin}); return promise; });