vault/ui/app/components/page/userpass-reset-password.js
Vault Automation b79dcd715a
[UI] Ember Data Migration - Auth Method/Config Cleanup (#9033) (#9058)
* removes remaining instances of auth-method model/adapter use

* removes auth method and config models/adapters/serializers

* fixes field to attrs tests

* fixes mfa tests

* fixes password reset

Co-authored-by: Jordan Reimer <zofskeez@gmail.com>
Co-authored-by: Jordan Reimer <jordan.reimer@hashicorp.com>
2025-09-04 11:00:29 -06:00

43 lines
1.1 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { task } from 'ember-concurrency';
export default class PageUserpassResetPasswordComponent extends Component {
@service flashMessages;
@service api;
@tracked newPassword = '';
@tracked error = '';
onSuccess() {
this.error = '';
this.newPassword = '';
this.flashMessages.success('Successfully reset password');
}
@task
*updatePassword(evt) {
evt.preventDefault();
this.error = '';
const { backend, username } = this.args;
if (!backend || !username) return;
if (!this.newPassword) {
this.error = 'Please provide a new password.';
return;
}
try {
yield this.api.auth.userpassResetPassword(username, backend, { password: this.newPassword });
this.onSuccess();
} catch (e) {
const { message } = yield this.api.parseError(e, 'Check Vault logs for details');
this.error = message;
}
}
}