2023-03-01 09:39:41 -06:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2024-05-31 11:29:24 -07:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-01 09:39:41 -06:00
|
|
|
*/
|
|
|
|
|
|
2020-09-14 15:58:06 -04:00
|
|
|
import Route from '@ember/routing/route';
|
2020-09-14 16:50:17 -04:00
|
|
|
import { inject as service } from '@ember/service';
|
2020-09-14 15:58:06 -04:00
|
|
|
|
|
|
|
|
export default class ScopesScopeAuthMethodsAuthMethodAccountsRoute extends Route {
|
2020-09-14 16:50:17 -04:00
|
|
|
// =services
|
|
|
|
|
|
2022-11-07 15:17:23 -08:00
|
|
|
@service store;
|
2021-09-03 10:22:54 -07:00
|
|
|
@service can;
|
2022-01-03 12:12:53 -05:00
|
|
|
|
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]}}
|
|
|
|
|
*/
|
2022-01-14 16:56:59 -05:00
|
|
|
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;
|
2022-01-14 16:56:59 -05:00
|
|
|
let accounts;
|
|
|
|
|
|
2021-09-03 10:22:54 -07:00
|
|
|
if (
|
2022-01-31 12:02:37 -05:00
|
|
|
this.can.can('list model', authMethod, {
|
2021-09-03 10:22:54 -07:00
|
|
|
collection: 'accounts',
|
|
|
|
|
})
|
|
|
|
|
) {
|
2022-01-14 16:56:59 -05:00
|
|
|
accounts = await this.store.query('account', { auth_method_id });
|
2021-09-03 10:22:54 -07:00
|
|
|
}
|
2022-01-14 16:56:59 -05:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
authMethod,
|
|
|
|
|
accounts,
|
|
|
|
|
};
|
2020-09-14 15:58:06 -04:00
|
|
|
}
|
|
|
|
|
}
|