#330: do not alter payload in ForgotPasswordState. Just pass it through

This commit is contained in:
SleepWalker 2017-04-21 08:28:19 +03:00
parent 852e073d37
commit 692e9b0ccd
3 changed files with 10 additions and 12 deletions

View File

@ -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 {
<p className={styles.descriptionText}>
<Message {...messages.specifyEmail} />
</p>
<Input {...this.bindField('email')}
<Input {...this.bindField('login')}
icon="envelope"
color="lightViolet"
required
@ -63,8 +63,8 @@ export default class ForgotPasswordBody extends BaseAuthBody {
serialize() {
const data = super.serialize();
if (!data.email) {
data.email = this.getLogin();
if (!data.login) {
data.login = this.getLogin();
}
return data;
@ -83,6 +83,6 @@ export default class ForgotPasswordBody extends BaseAuthBody {
this.context.requestRedraw();
// TODO: requestRedraw должен возвращать promise, по которому нужно ставить фокус на поле
// иначе же, если фокус ставить сразу, то форма скачет
setTimeout(() => {this.form.focus('email');}, 300);
setTimeout(() => {this.form.focus('login');}, 300);
};
}

View File

@ -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 = {}) =>

View File

@ -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;
});