* refactor: 💡 account and auth-method abilities * refactor: 💡 add update & delete abilities & unit tests
45 lines
881 B
JavaScript
45 lines
881 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
*/
|
|
|
|
import ModelAbility from './model';
|
|
|
|
/**
|
|
* Provides abilities for accounts.
|
|
*/
|
|
export default class AccountAbility extends ModelAbility {
|
|
// =permissions
|
|
|
|
/**
|
|
* Only "known" account types may be read.
|
|
* @type {boolean}
|
|
*/
|
|
get canRead() {
|
|
return !this.model.isUnknown && this.hasAuthorizedAction('read');
|
|
}
|
|
|
|
/**
|
|
* Only "known" account types may be updated.
|
|
* @type {boolean}
|
|
*/
|
|
get canUpdate() {
|
|
return !this.model.isUnknown && this.hasAuthorizedAction('update');
|
|
}
|
|
|
|
/**
|
|
* Only "known" account types may be deleted.
|
|
* @type {boolean}
|
|
*/
|
|
get canDelete() {
|
|
return !this.model.isUnknown && this.hasAuthorizedAction('delete');
|
|
}
|
|
|
|
/**
|
|
* @type {boolean}
|
|
*/
|
|
get canSetPassword() {
|
|
return this.hasAuthorizedAction('set-password');
|
|
}
|
|
}
|