feat: 🎸 add make/remove primary to auth method list
This commit is contained in:
6 files changed
+65
-10
No files matched your search
@@ -5,7 +5,7 @@ import { getOwner } from '@ember/application';
|
||||
* confirmation via the confirmation service. If the user accepts, the
|
||||
* original method is executed. If the user denies, it is not.
|
||||
*/
|
||||
export function confirm(confirmationTextKey) {
|
||||
export function confirm(confirmationTextKey, options) {
|
||||
return function (_target, _propertyKey, desc) {
|
||||
const method = desc.value;
|
||||
desc.value = function () {
|
||||
@@ -15,7 +15,7 @@ export function confirm(confirmationTextKey) {
|
||||
const text = intl.t(confirmationTextKey);
|
||||
return (
|
||||
confirmService
|
||||
.confirm(text)
|
||||
.confirm(text, options)
|
||||
// If user confirmed, execute the decorated method
|
||||
.then(() => method.apply(this, arguments))
|
||||
// If the user denied, gracefully handle promise rejection with no-op
|
||||
|
||||
@@ -16,7 +16,7 @@ account:
|
||||
auth-method:
|
||||
title: Auth Method
|
||||
title_plural: Auth Methods
|
||||
description: Auth methods govern how an org's users can login to Boundary. Boundary’s default auth method is username & passwords.
|
||||
description: Auth methods enable authentication within a scope. The primary auth method within a scope auto-creates users on their first authentication attempt.
|
||||
messages:
|
||||
welcome:
|
||||
title: Welcome to Auth Methods
|
||||
@@ -25,8 +25,8 @@ auth-method:
|
||||
title: No Auth Methods
|
||||
description: No auth methods were found for this scope.
|
||||
no-primary-auth-method:
|
||||
title: No Primary Auth Method Found
|
||||
description: A primary auth method auto-vivifies users when they authenticate for the first time. The primary auth method is also presented first to unauthenticated users. Each scope may have one primary auth method. Please choose a primary auth method for this scope.
|
||||
title: "Recommendation: Select a Primary Auth Method"
|
||||
description: A primary auth method auto-creates users when they authenticate for the first time. Scopes without primary auth methods may experience authentication failures.
|
||||
types:
|
||||
password: Password
|
||||
actions:
|
||||
@@ -38,8 +38,10 @@ auth-method:
|
||||
make-primary-success: Auth method successfully elected to primary.
|
||||
remove-as-primary-success: Auth method successfully removed as primary.
|
||||
questions:
|
||||
make-primary-confirm: Are you sure you want to elect this auth method to primary?
|
||||
remove-as-primary-confirm: Are you sure you want to remove as primary this auth method? A primary auth method is recommended for every scope.
|
||||
make-primary: Make primary auth method?
|
||||
remove-as-primary: Remove primary auth method?
|
||||
make-primary-confirm: "A primary auth method auto-creates users on their first authentication attempt if needed. Note: if you change the primary auth method, the previous primary will no longer auto-create users."
|
||||
remove-as-primary-confirm: Removing the primary auth method may lead to authentication failures for this scope.
|
||||
group:
|
||||
title: Group
|
||||
title_plural: Groups
|
||||
|
||||
@@ -87,7 +87,9 @@ export default class ScopesScopeAuthMethodsRoute extends Route {
|
||||
*/
|
||||
@action
|
||||
@loading
|
||||
@confirm('resources.auth-method.questions.make-primary-confirm')
|
||||
@confirm('resources.auth-method.questions.make-primary-confirm', {
|
||||
title: 'resources.auth-method.questions.make-primary',
|
||||
})
|
||||
@notifyError(({ message }) => message, { catch: true })
|
||||
@notifySuccess('resources.auth-method.notifications.make-primary-success')
|
||||
async makePrimary({ id }) {
|
||||
@@ -112,7 +114,9 @@ export default class ScopesScopeAuthMethodsRoute extends Route {
|
||||
*/
|
||||
@action
|
||||
@loading
|
||||
@confirm('resources.auth-method.questions.remove-as-primary-confirm')
|
||||
@confirm('resources.auth-method.questions.remove-as-primary-confirm', {
|
||||
title: 'resources.auth-method.questions.remove-as-primary',
|
||||
})
|
||||
@notifyError(({ message }) => message, { catch: true })
|
||||
@notifySuccess(
|
||||
'resources.auth-method.notifications.remove-as-primary-success'
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
</Rose::Dialog>
|
||||
{{else}}
|
||||
<Rose::Dialog
|
||||
@heading={{t "actions.confirm"}}
|
||||
@heading={{if confirmation.options.title (t confirmation.options.title) (t "actions.confirm")}}
|
||||
@dismissButtonText={{t "actions.cancel"}}
|
||||
@icon="alert-triangle"
|
||||
@style="warning"
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
<row.headerCell>{{t 'form.id.label'}}</row.headerCell>
|
||||
{{#if (feature-flag 'primary-auth-method')}}
|
||||
<row.cell></row.cell>
|
||||
<row.headerCell>{{t 'titles.actions'}}</row.headerCell>
|
||||
{{/if}}
|
||||
</header.row>
|
||||
</table.header>
|
||||
@@ -87,6 +88,30 @@
|
||||
</Rose::Badge>
|
||||
{{/if}}
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<Rose::Dropdown
|
||||
@text={{t "titles.actions"}}
|
||||
@dropdownRight={{true}}
|
||||
@iconOnly={{true}}
|
||||
@showCaret={{false}}
|
||||
@icon="more-horizontal"
|
||||
as |dropdown|>
|
||||
{{#unless authMethod.isPrimary}}
|
||||
<dropdown.button
|
||||
{{on "click" (route-action "makePrimary" authMethod)}}
|
||||
>
|
||||
{{t 'resources.auth-method.actions.make-primary'}}
|
||||
</dropdown.button>
|
||||
{{/unless}}
|
||||
{{#if authMethod.isPrimary}}
|
||||
<dropdown.button
|
||||
{{on "click" (route-action "removeAsPrimary" authMethod)}}
|
||||
>
|
||||
{{t 'resources.auth-method.actions.remove-as-primary'}}
|
||||
</dropdown.button>
|
||||
{{/if}}
|
||||
</Rose::Dropdown>
|
||||
</row.cell>
|
||||
{{/if}}
|
||||
</body.row>
|
||||
{{/each}}
|
||||
|
||||
@@ -361,4 +361,28 @@ module('Acceptance | auth methods', function (hooks) {
|
||||
);
|
||||
assert.ok(find('.rose-notification'));
|
||||
});
|
||||
|
||||
test('user can make and remove primary auth methods from index', async function (assert) {
|
||||
assert.expect(3);
|
||||
assert.notOk(
|
||||
instances.scopes.org.primaryAuthMethodId,
|
||||
'Primary auth method is not yet set.'
|
||||
);
|
||||
enableFeature('primary-auth-method');
|
||||
await visit(urls.authMethods);
|
||||
await click(
|
||||
'.rose-table-body .rose-table-row:first-child .rose-dropdown-content [type="button"]:first-child'
|
||||
);
|
||||
let scope = this.server.schema.scopes.find(instances.scopes.org.id);
|
||||
assert.equal(
|
||||
scope.primaryAuthMethodId,
|
||||
instances.authMethod.id,
|
||||
'Primary auth method is set.'
|
||||
);
|
||||
await click(
|
||||
'.rose-table-body .rose-table-row:first-child .rose-dropdown-content [type="button"]:first-child'
|
||||
);
|
||||
scope = this.server.schema.scopes.find(instances.scopes.org.id);
|
||||
assert.notOk(scope.primaryAuthMethodId, 'Primary auth method is unset.');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user