@fleetbase/iam-engine
Version:
Fleetbase IAM extension provides identity and access management module for managing users, permissions and policies.
50 lines (42 loc) • 1.57 kB
JavaScript
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
export default class ModalsChangeUserPasswordComponent extends Component {
fetch;
notifications;
options = {};
password;
confirmPassword;
sendCredentials = true;
user;
constructor(owner, { options }) {
super(...arguments);
this.user = options.user;
this.options = options;
this.setupOptions();
}
setupOptions() {
this.options.title = 'Reset User Credentials';
this.options.acceptButtonText = 'Reset Credentials';
this.options.declineButtonHidden = true;
this.options.confirm = async (modal) => {
modal.startLoading();
try {
await this.fetch.post('auth/change-user-password', {
user: this.user.id,
password: this.password,
password_confirmation: this.confirmPassword,
send_credentials: this.sendCredentials,
});
this.notifications.success('User password reset.');
if (typeof this.options.onPasswordResetComplete === 'function') {
this.options.onPasswordResetComplete();
}
modal.done();
} catch (error) {
this.notifications.serverError(error);
modal.stopLoading();
}
};
}
}