From 187dd8a086c4f83e2186e0926da0b1508347dcda Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Mon, 18 Dec 2023 16:17:01 +0530 Subject: [PATCH 1/3] Implemented: permission support in app on login(#117) --- src/authorization/Actions.ts | 1 + src/authorization/Rules.ts | 1 + src/store/modules/user/actions.ts | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/authorization/Actions.ts b/src/authorization/Actions.ts index 29b1ecfc..8862acb0 100644 --- a/src/authorization/Actions.ts +++ b/src/authorization/Actions.ts @@ -1,2 +1,3 @@ export default { + "COMMON_ADMIN": "COMMON_ADMIN" } \ No newline at end of file diff --git a/src/authorization/Rules.ts b/src/authorization/Rules.ts index 72a86a17..615515a7 100644 --- a/src/authorization/Rules.ts +++ b/src/authorization/Rules.ts @@ -1,2 +1,3 @@ export default { + "COMMON_ADMIN": "COMMON_ADMIN" // TODO: update the permission check logic inside action, kept key as COMMON_ADMIN as the permission checking logic uses keys to check against the env value } as any \ No newline at end of file diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index b8e7652c..e73b740a 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -37,9 +37,9 @@ const actions: ActionTree = { if (permissionId) { // As the token is not yet set in the state passing token headers explicitly // TODO Abstract this out, how token is handled should be part of the method not the callee - const hasPermission = appPermissions.some((appPermissionId: any) => appPermissionId === permissionId ); + const hasPermission = appPermissions.some((appPermission: any) => appPermission.action === permissionId ); // If there are any errors or permission check fails do not allow user to login - if (hasPermission) { + if (!hasPermission) { const permissionError = 'You do not have permission to access the app.'; showToast(translate(permissionError)); logger.error("error", permissionError); From 00fd3b2d1cdf3f20ab10fba0a19561b6b7ef9705 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Mon, 18 Dec 2023 16:18:50 +0530 Subject: [PATCH 2/3] Improved: env.example file to permissionId for app access(#117) --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index a0a75169..86e0e4cc 100644 --- a/.env.example +++ b/.env.example @@ -3,7 +3,7 @@ VUE_APP_I18N_FALLBACK_LOCALE=en-US VUE_APP_CACHE_MAX_AGE=3600 VUE_APP_VIEW_SIZE=20 VUE_APP_BASE_URL= -VUE_APP_PERMISSION_ID= +VUE_APP_PERMISSION_ID="COMMON_ADMIN" VUE_APP_LOCALES={"en-US": "English"} VUE_APP_DEFAULT_LOG_LEVEL="error" VUE_APP_LOGIN_URL="http://launchpad.hotwax.io/login" \ No newline at end of file From 3820a69a79af3f9b6ba6c918a2e4dd22a22b3370 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Mon, 18 Dec 2023 16:28:34 +0530 Subject: [PATCH 3/3] Improved: permissionId for app access(#117) --- .env.example | 2 +- src/authorization/Actions.ts | 2 +- src/authorization/Rules.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 86e0e4cc..c5a895e9 100644 --- a/.env.example +++ b/.env.example @@ -3,7 +3,7 @@ VUE_APP_I18N_FALLBACK_LOCALE=en-US VUE_APP_CACHE_MAX_AGE=3600 VUE_APP_VIEW_SIZE=20 VUE_APP_BASE_URL= -VUE_APP_PERMISSION_ID="COMMON_ADMIN" +VUE_APP_PERMISSION_ID="FACILITIES_APP_VIEW" VUE_APP_LOCALES={"en-US": "English"} VUE_APP_DEFAULT_LOG_LEVEL="error" VUE_APP_LOGIN_URL="http://launchpad.hotwax.io/login" \ No newline at end of file diff --git a/src/authorization/Actions.ts b/src/authorization/Actions.ts index 8862acb0..c483ab02 100644 --- a/src/authorization/Actions.ts +++ b/src/authorization/Actions.ts @@ -1,3 +1,3 @@ export default { - "COMMON_ADMIN": "COMMON_ADMIN" + "FACILITIES_APP_VIEW": "FACILITIES_APP_VIEW" } \ No newline at end of file diff --git a/src/authorization/Rules.ts b/src/authorization/Rules.ts index 615515a7..8715cb41 100644 --- a/src/authorization/Rules.ts +++ b/src/authorization/Rules.ts @@ -1,3 +1,3 @@ export default { - "COMMON_ADMIN": "COMMON_ADMIN" // TODO: update the permission check logic inside action, kept key as COMMON_ADMIN as the permission checking logic uses keys to check against the env value + "FACILITIES_APP_VIEW": "FACILITIES_APP_VIEW" } as any \ No newline at end of file