Merge pull request #185 from hashicorp/ICU-580-set-a-new-password

Set an account's password
This commit is contained in:
Randall Morey authored and GitHub committed 2020-09-16 11:26:49 -04:00
commit cf94affe05
8 files changed
+120 -1

No files matched your search

@@ -0,0 +1,32 @@
<Rose::Form
@onSubmit={{@submit}}
@cancel={{@cancel}}
@disabled={{@model.isSaving}}
@error={{@model.errors.base}}
as |form|
>
<form.input
@name="password"
@type="password"
@value={{@model.attributes.password}}
@label={{t "form.label.password"}}
@error={{@model.errors.name}}
readonly={{false}}
autocomplete="new-password"
as |field|>
{{#if @model.errors.name}}
<field.errors as |errors|>
{{#each @model.errors.name as |error|}}
<errors.message>{{error.message}}</errors.message>
{{/each}}
</field.errors>
{{/if}}
</form.input>
<form.actions
@disabled={{if @model.cannotSave @model.cannotSave}}
@submitText={{t "actions.save"}}
@cancelText={{t "actions.cancel"}} />
</Rose::Form>
+3 -1
View File
@@ -74,7 +74,9 @@ Router.map(function () {
this.route('auth-methods', function() {
this.route('auth-method', { path: ':auth_method_id' }, function() {
this.route('accounts', function() {
this.route('account', { path: ':account_id' }, function() {});
this.route('account', { path: ':account_id' }, function() {
this.route('settings');
});
this.route('new');
});
});
@@ -0,0 +1,39 @@
import Route from '@ember/routing/route';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
export default class ScopesScopeAuthMethodsAuthMethodAccountsAccountSettingsRoute extends Route {
// =services
@service intl;
@service notify;
// =actions
/**
* Set password for current account.
* @param {AccountModel} account
*/
@action
async setPassword(account) {
try {
await account.setPassword();
await this.replaceWith('scopes.scope.auth-methods.auth-method.accounts.account.settings');
this.notify.success(
this.intl.t('notify.save-success')
);
} catch (error) {
// TODO: replace with translated strings
this.notify.error(error.message, { closeAfter: null });
}
}
/**
* Redirect to hosts as if nothing ever happened.
*/
@action
cancel() {
this.replaceWith('scopes.scope.auth-methods.auth-method.accounts.account');
}
}
@@ -2,4 +2,7 @@
<nav.link @route='scopes.scope.auth-methods.auth-method.accounts.account.index'>
{{t 'titles.details'}}
</nav.link>
<nav.link @route='scopes.scope.auth-methods.auth-method.accounts.account.settings'>
{{t 'titles.settings'}}
</nav.link>
</Rose::Nav::Tabs>
@@ -0,0 +1,7 @@
<p>{{t 'descriptions.account-settings-overview'}}</p>
<Form::Account::Password::SetPassword
@model={{@model}}
@submit={{route-action "setPassword" @model}}
@cancel={{route-action "cancel" @model}}
/>
@@ -0,0 +1,24 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, find } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | form/account/password/set-password', function(hooks) {
setupRenderingTest(hooks);
test('it renders', async function(assert) {
this.submit = () => {};
this.cancel = () => {};
this.model = { type: 'password' };
await render(hbs`
<Form::Account::Password::SetPassword
@model={{this.model}}
@submit={{this.submit}}
@cancel={{this.cancel}}
/>`);
assert.ok(find('form'));
});
});
@@ -0,0 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Route | scopes/scope/auth-methods/auth-method/accounts/account/settings', function(hooks) {
setupTest(hooks);
test('it exists', function(assert) {
let route = this.owner.lookup('route:scopes/scope/auth-methods/auth-method/accounts/account/settings');
assert.ok(route);
});
});
+1
View File
@@ -132,6 +132,7 @@ descriptions:
no-principals-available: Principals are not available for assignment.
group-members-welcome: Users belonging to this group appear here.
no-available-users: No users are available to add to this group.
account-settings-overview: Set the password for current account.
accounts-welcome: No accounts are available in this auth method.
states:
info: Info