0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

🐛 fix display/message bugs in re-auth modal (#770)

closes https://github.com/TryGhost/Ghost/issues/8656
- prevents button stretching from flexbox and adds margin between input and button
- use the `context` attribute returned from the server instead of the `message` so the error is now `Your password is incorrect.` instead of `You are not authorised to make this request.`
- return truthy/falsy values from the auth tasks so that the save-state button shows the correct state
This commit is contained in:
Kevin Ansfield 2017-07-06 11:18:20 +01:00 committed by Aileen Nowak
parent fc706d1c02
commit 036ab413d3
2 changed files with 8 additions and 4 deletions

View file

@ -45,16 +45,17 @@ export default ModalComponent.extend(ValidationEngine, {
this.set('authenticationError', null); this.set('authenticationError', null);
return this.validate({property: 'signin'}).then(() => { return this.validate({property: 'signin'}).then(() => {
this._authenticate().then(() => { return this._authenticate().then(() => {
this.get('notifications').closeAlerts(); this.get('notifications').closeAlerts();
this.send('closeModal'); this.send('closeModal');
return true;
}).catch((error) => { }).catch((error) => {
if (error && error.errors) { if (error && error.errors) {
error.errors.forEach((err) => { error.errors.forEach((err) => {
if (isVersionMismatchError(err)) { if (isVersionMismatchError(err)) {
return this.get('notifications').showAPIError(error); return this.get('notifications').showAPIError(error);
} }
err.message = htmlSafe(err.message); err.message = htmlSafe(err.context || err.message);
}); });
this.get('errors').add('password', 'Incorrect password'); this.get('errors').add('password', 'Incorrect password');
@ -64,6 +65,7 @@ export default ModalComponent.extend(ValidationEngine, {
}); });
}, () => { }, () => {
this.get('hasValidated').pushObject('password'); this.get('hasValidated').pushObject('password');
return false;
}); });
}, },
@ -95,9 +97,9 @@ export default ModalComponent.extend(ValidationEngine, {
reauthenticate: task(function* () { reauthenticate: task(function* () {
if (this.get('config.ghostOAuth')) { if (this.get('config.ghostOAuth')) {
yield this._oauthConfirm(); return yield this._oauthConfirm();
} else { } else {
yield this._passwordConfirm(); return yield this._passwordConfirm();
} }
}).drop(), }).drop(),

View file

@ -183,8 +183,10 @@
@media (min-width: 901px) { @media (min-width: 901px) {
.modal-body .login-form { .modal-body .login-form {
display: flex; display: flex;
align-items: center;
} }
.modal-body .login-form .password-wrap { .modal-body .login-form .password-wrap {
flex: 1; flex: 1;
margin-right: 10px;
} }
} }