Files
threshold-ui/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts.js
T

39 lines
832 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
2020-09-14 15:58:06 -04:00
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
2020-09-14 15:58:06 -04:00
export default class ScopesScopeAuthMethodsAuthMethodAccountsRoute extends Route {
// =services
@service store;
2021-09-03 10:22:54 -07:00
@service can;
2020-09-14 15:58:06 -04:00
// =methods
/**
2020-09-16 09:48:07 -04:00
* Returns accounts for the current auth method.
2020-09-14 15:58:06 -04:00
* @return {Promise{[AccountModel]}}
*/
async model() {
2021-09-03 10:22:54 -07:00
const authMethod = this.modelFor('scopes.scope.auth-methods.auth-method');
const { id: auth_method_id } = authMethod;
let accounts;
2021-09-03 10:22:54 -07:00
if (
this.can.can('list model', authMethod, {
2021-09-03 10:22:54 -07:00
collection: 'accounts',
})
) {
accounts = await this.store.query('account', { auth_method_id });
2021-09-03 10:22:54 -07:00
}
return {
authMethod,
accounts,
};
2020-09-14 15:58:06 -04:00
}
}