Merge pull request #2566 from richard-cox/block-delete-self

Ensure current user cannot deactivate or delete themselves
This commit is contained in:
Richard Cox 2021-03-19 09:19:57 +00:00 committed by GitHub
commit 83492e663d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -11,6 +11,12 @@ export default {
return false;
},
isCurrentUser() {
const currentPrincipal = this.$rootGetters['auth/principalId'];
return !!this.principalIds.find(p => p === currentPrincipal);
},
nameDisplay() {
return this.displayName || this.username || this.id;
},
@ -136,10 +142,14 @@ export default {
const stateOk = state ? this.state === 'inactive' : this.state === 'active';
const permissionOk = this.hasLink('update'); // Not canUpdate, only gate on api not whether editable pages should be visible
return stateOk && permissionOk;
return stateOk && permissionOk && !this.isCurrentUser;
};
},
canDelete() {
return this._canDelete && !this.isCurrentUser;
},
_availableActions() {
return [
{

View File

@ -702,6 +702,10 @@ export default {
// ------------------------------------------------------------------
canDelete() {
return this._canDelete;
},
_canDelete() {
return this.hasLink('remove') && this.$rootGetters['type-map/optionsFor'](this.type).isRemovable;
},