2023-03-01 09:39:41 -06:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2021-03-26 09:41:07 -04:00
|
|
|
import Controller from '@ember/controller';
|
2024-03-18 10:34:54 -07:00
|
|
|
import { action } from '@ember/object';
|
2021-03-26 09:41:07 -04:00
|
|
|
|
|
|
|
|
export default class ScopesScopeAuthMethodsIndexController extends Controller {
|
2021-03-26 11:33:43 -04:00
|
|
|
// =attributes
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* True if the current scope has a primary auth method set.
|
|
|
|
|
* @type {boolean}
|
|
|
|
|
*/
|
2021-03-26 09:41:07 -04:00
|
|
|
get hasPrimaryAuthMethod() {
|
2021-03-30 10:34:15 -04:00
|
|
|
return Boolean(this.scopeModel.primary_auth_method_id);
|
2021-03-26 09:41:07 -04:00
|
|
|
}
|
2024-03-18 10:34:54 -07:00
|
|
|
|
|
|
|
|
// =actions
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes an item from array `property` at `index` on the
|
|
|
|
|
* passed `authMethod`. This is used to manage entries in fragment array
|
|
|
|
|
* fields such as `signing_algorithms`.
|
|
|
|
|
* @param {AuthMethodModel} authMethod
|
|
|
|
|
* @param {string} property
|
|
|
|
|
* @param {number} index
|
|
|
|
|
*/
|
|
|
|
|
@action
|
|
|
|
|
async removeItemByIndex(authMethod, property, index) {
|
|
|
|
|
const array = authMethod.get(property).filter((item, i) => i !== index);
|
|
|
|
|
authMethod.set(property, array);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a string item to array `property` on the passed `authMethod`.
|
|
|
|
|
* This is used to manage entries in fragment OIDC string array fields such
|
|
|
|
|
* as `signing_algorithms`.
|
|
|
|
|
* @param {AuthMethodModel} authMethod
|
|
|
|
|
* @param {string} property
|
|
|
|
|
* @param {string} value
|
|
|
|
|
*/
|
|
|
|
|
@action
|
|
|
|
|
async addStringItem(authMethod, property, value) {
|
|
|
|
|
const existingArray = authMethod[property] ?? [];
|
|
|
|
|
const array = [...existingArray, { value }];
|
|
|
|
|
authMethod.set(property, array);
|
|
|
|
|
}
|
2021-03-26 09:41:07 -04:00
|
|
|
}
|