Files
threshold-ui/ui/admin/app/controllers/account/change-password.js
T
Zhihe Li 999c21c66a Upgrade eslint (#3175)
* chore: 🤖 Upgrade eslint config for admin ui

* chore: 🤖 Fix eslint issues for admin

* chore: 🤖 Upgrade eslint config for desktop

* chore: 🤖 Fix linting errors in desktop

* chore: 🤖 Upgrade eslint for api addon

* chore: 🤖 Fix eslint issues in api addon

* chore: 🤖 Upgrade eslint for auth addon

* chore: 🤖 Fix eslint issues in auth addon

* chore: 🤖 Upgrade core eslint config

* chore: 🤖 Fix eslint issue for core addon

* chore: 🤖 Upgrade eslint config for rose addon

* chore: 🤖 Fix eslint issue for rose addon

* chore: 🤖 Upgrade e2e eslint config

* chore: 🤖 Fix eslint issues in e2e

* chore: 🤖 Fix CI linting issues

* chore: 🤖 Add back linting server files for the future

* chore: 🤖 Update qunit rules to use extends
2026-02-27 13:32:27 -05:00

50 lines
1.4 KiB
JavaScript

/**
* Copyright IBM Corp. 2021, 2026
* SPDX-License-Identifier: BUSL-1.1
*/
import Controller from '@ember/controller';
import { service } from '@ember/service';
import { action } from '@ember/object';
import { notifySuccess, notifyError } from 'core/decorators/notify';
export default class AccountChangePasswordController extends Controller {
// =services
@service session;
@service router;
// =actions
/**
* Changes the password on the account and then redirects to the index route.
* @param {AccountModel} account
* @param {string} currentPassword
* @param {string} newPassword
*/
@action
@notifyError(({ message }) => message, { catch: true })
@notifySuccess('notifications.save-success')
async changePassword(account, currentPassword, newPassword) {
await account.changePassword(currentPassword, newPassword);
// Transition to index after success. We ignore errors in the transition,
// since the index route is responsible for additional
// redirects depending on the authentication context. These additional
// redirects may abort this initial transition, resulting in a
// TransitionAborted error, which we do not want to show to the user.
try {
await this.router.replaceWith('index');
} catch {
// no-op
}
}
/**
* On cancel, redirects to index route for further processing.
*/
@action
cancel() {
this.router.replaceWith('index');
}
}