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-08-12 17:16:41 -04:00
|
|
|
import Route from '@ember/routing/route';
|
2022-11-07 15:17:23 -08:00
|
|
|
import { inject as service } from '@ember/service';
|
2023-11-02 16:08:25 -07:00
|
|
|
import { paramValueFinder } from 'admin/utils/param-value-finder';
|
|
|
|
|
|
2020-08-12 17:16:41 -04:00
|
|
|
export default class ScopesScopeAuthMethodsAuthMethodRoute extends Route {
|
2022-11-07 15:17:23 -08:00
|
|
|
// =services
|
|
|
|
|
|
|
|
|
|
@service store;
|
2023-11-02 16:08:25 -07:00
|
|
|
@service can;
|
|
|
|
|
@service router;
|
2022-11-07 15:17:23 -08:00
|
|
|
|
2020-08-12 17:16:41 -04:00
|
|
|
// =methods
|
|
|
|
|
|
|
|
|
|
/**
|
2020-09-16 09:48:07 -04:00
|
|
|
* Load an auth method by ID.
|
2020-08-12 17:16:41 -04:00
|
|
|
* @param {object} params
|
|
|
|
|
* @param {string} params.auth_method_id
|
2023-11-02 16:08:25 -07:00
|
|
|
* @return {Promise{AuthMethodModel}}
|
2020-08-12 17:16:41 -04:00
|
|
|
*/
|
2020-09-09 12:24:01 -04:00
|
|
|
async model({ auth_method_id }) {
|
2023-11-02 16:08:25 -07:00
|
|
|
return this.store.findRecord('auth-method', auth_method_id, {
|
|
|
|
|
reload: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Redirects to route with correct scope id if incorrect.
|
|
|
|
|
* @param {AuthMethodModel} authMethod
|
|
|
|
|
* @param {object} transition
|
|
|
|
|
*/
|
|
|
|
|
redirect(authMethod, transition) {
|
|
|
|
|
const scope = this.modelFor('scopes.scope');
|
|
|
|
|
if (authMethod.scopeID !== scope.id) {
|
|
|
|
|
let paramValues = paramValueFinder('auth-method', transition.to.parent);
|
|
|
|
|
this.router.replaceWith(
|
|
|
|
|
transition.to.name,
|
|
|
|
|
authMethod.scopeID,
|
|
|
|
|
authMethod.id,
|
2023-11-22 14:07:41 -05:00
|
|
|
...paramValues,
|
2023-11-02 16:08:25 -07:00
|
|
|
);
|
|
|
|
|
}
|
2020-08-12 17:16:41 -04:00
|
|
|
}
|
|
|
|
|
}
|