Skip to content

Commit

Permalink
Merge pull request #159 from amansinghbais/158-permission-management
Browse files Browse the repository at this point in the history
Improved: added the permision check for the security group create and permission association action (#158)
  • Loading branch information
ravilodhi authored Mar 8, 2024
2 parents c3788f0 + 50852c3 commit 2db5b5c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/authorization/Actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export default {
'APP_UPDT_PRODUCT_STORE_CONFG': 'APP_UPDT_PRODUCT_STORE_CONFG',
'APP_SUPER_USER': 'APP_SUPER_USER',
'APP_SECURITY_GROUP_CREATE': 'APP_SECURITY_GROUP_CREATE',
'APP_PERMISSION_UPDATE': 'APP_PERMISSION_UPDATE',
'APP_USER_CREATE': 'APP_USER_CREATE'
}
1 change: 1 addition & 0 deletions src/authorization/Rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default {
'APP_UPDT_PASSWORD': 'SECURITY_CREATE OR SECURITY_ADMIN',
'APP_UPDT_PRODUCT_STORE_CONFG': 'SECURITY_CREATE OR SECURITY_ADMIN',
'APP_SECURITY_GROUP_CREATE': 'SECURITY_CREATE OR SECURITY_ADMIN',
'APP_PERMISSION_UPDATE': 'SECURITY_CREATE OR SECURITY_ADMIN',
'APP_SUPER_USER': 'WEBTOOLS_VIEW',
'USERS_APP_VIEW': 'USERS_APP_VIEW'
} as any
5 changes: 4 additions & 1 deletion src/components/PermissionItems.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<ion-card-title>{{ permission.permissionId }}</ion-card-title>
<ion-card-subtitle>{{ getPermissionDescription(permission.permissionId) }}</ion-card-subtitle>
</div>
<ion-checkbox :checked="permission.isChecked" @click="updatePermissionAssociation($event, permission)" />
<ion-checkbox :disabled="!hasPermission(Actions.APP_PERMISSION_UPDATE)" :checked="permission.isChecked" @click="updatePermissionAssociation($event, permission)" />
</ion-card-header>
</ion-card>
</section>
Expand Down Expand Up @@ -58,6 +58,7 @@ import { PermissionService } from '@/services/PermissionService';
import { showToast } from '@/utils';
import { hasError } from '@/adapter';
import { DateTime } from 'luxon';
import { Actions, hasPermission } from '@/authorization'
export default defineComponent({
name: 'PermissionItems',
Expand Down Expand Up @@ -150,6 +151,8 @@ export default defineComponent({
const store = useStore();
return {
Actions,
hasPermission,
shieldCheckmarkOutline,
store,
translate
Expand Down
5 changes: 4 additions & 1 deletion src/views/Permissions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</ion-item>
</ion-list>

<ion-button @click="createGroup()" fill="clear" expand="block">
<ion-button @click="createGroup()" :disabled="!hasPermission(Actions.APP_SECURITY_GROUP_CREATE)" fill="clear" expand="block">
<ion-icon slot="start" :icon="addOutline" />
<ion-label>{{ translate("Create security group") }}</ion-label>
</ion-button>
Expand Down Expand Up @@ -86,6 +86,7 @@ import emitter from "@/event-bus";
import { PermissionService } from '@/services/PermissionService';
import { DateTime } from 'luxon';
import EditSecurityGroupModal from '@/components/EditSecurityGroupModal.vue';
import { Actions, hasPermission } from '@/authorization'
export default defineComponent({
name: 'Permissions',
Expand Down Expand Up @@ -254,8 +255,10 @@ export default defineComponent({
const store = useStore();
return {
Actions,
addOutline,
downloadOutline,
hasPermission,
idCardOutline,
openOutline,
router,
Expand Down

0 comments on commit 2db5b5c

Please sign in to comment.