mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-27 01:02:14 +05:30
#330: do not alter payload in ForgotPasswordState. Just pass it through
This commit is contained in:
parent
852e073d37
commit
692e9b0ccd
@ -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);
|
||||
};
|
||||
}
|
||||
|
@ -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 = {}) =>
|
||||
|
@ -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;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user