🐛 Fixed success state on change password button. (#17410)

closes https://github.com/TryGhost/Product/issues/3604

- The change password button in the user settings wasn't updating correctly.
- the saveNewPasswordTask() wasn't returning anything, causing `
this.get('task.last.value')` to return undefined in the `isSuccess`
method.
- This fix ensures that there is a value attached to the
`task.last.value` so that the condition for a successful save checks
out.

---

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at a6a76eb</samp>

Improved error handling and feedback for changing user passwords in the
settings UI. Modified `saveNewPasswordTask` function in
`ghost/admin/app/controllers/settings/staff/user.js` to catch and
display errors and return user object.
This commit is contained in:
Ronald Langeveld 2023-07-18 17:58:06 +02:00 committed by GitHub
parent 368f6c57a6
commit 6dc000e247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -326,8 +326,15 @@ export default class UserController extends Controller {
@task
*saveNewPasswordTask() {
yield this.user.saveNewPasswordTask.perform();
document.querySelector('#password-reset')?.reset();
try {
const user = yield this.user.saveNewPasswordTask.perform();
document.querySelector('#password-reset')?.reset();
return user;
} catch (error) {
if (error) {
this.notifications.showAPIError(error, {key: 'user.update'});
}
}
}
@action