@finema/finework-layer 1.0.65 → 1.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.67](https://gitlab.finema.co/finema/finework/finework-frontend-layer/compare/1.0.66...1.0.67) (2026-05-26)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* refactor permission check logic to use 'some' instead of spreading all permissions ([bdcaeee](https://gitlab.finema.co/finema/finework/finework-frontend-layer/commit/bdcaeeecb685b8556544ab6ca46f575061b44675))
|
|
8
|
+
|
|
9
|
+
## [1.0.66](https://gitlab.finema.co/finema/finework/finework-frontend-layer/compare/1.0.65...1.0.66) (2026-05-26)
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* enhance permission system to support custom string-based permissions ([94cb037](https://gitlab.finema.co/finema/finework/finework-frontend-layer/commit/94cb0376f33c9e9f76b4cc63ee84c3fe44b41880))
|
|
14
|
+
|
|
3
15
|
## [1.0.65](https://gitlab.finema.co/finema/finework/finework-frontend-layer/compare/1.0.64...1.0.65) (2026-05-26)
|
|
4
16
|
|
|
5
17
|
## [1.0.64](https://gitlab.finema.co/finema/finework/finework-frontend-layer/compare/1.0.63...1.0.64) (2026-05-25)
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
import type { NavigationMenuItem } from '@nuxt/ui'
|
|
189
189
|
import { computed } from 'vue'
|
|
190
190
|
import { useRoute } from 'vue-router'
|
|
191
|
-
import type {
|
|
191
|
+
import type { UserModule } from '#imports'
|
|
192
192
|
import Navbar from '../Apps.vue'
|
|
193
193
|
|
|
194
194
|
defineEmits<{
|
|
@@ -306,21 +306,15 @@ const filterItems = (items: NavigationMenuItem[]): NavigationMenuItem[] => {
|
|
|
306
306
|
// permissions: ['pmo:USER', 'pmo:ADMIN', 'pmo:SUPER'] => module: 'pmo', permissions: ['USER', 'ADMIN', 'SUPER']
|
|
307
307
|
const permissionStrings = item.permissions as string[]
|
|
308
308
|
|
|
309
|
-
|
|
310
|
-
|
|
309
|
+
return permissionStrings
|
|
310
|
+
.map((p) => p.split(':'))
|
|
311
|
+
.some(([moduleStr, permission]) => {
|
|
312
|
+
if (!moduleStr || !permission) {
|
|
313
|
+
return false
|
|
314
|
+
}
|
|
311
315
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const [moduleStr] = firstPermission.split(':')
|
|
317
|
-
|
|
318
|
-
// Extract all permission levels
|
|
319
|
-
const permissionLevels = permissionStrings.map(
|
|
320
|
-
(p) => p.split(':')[1],
|
|
321
|
-
) as Permission[]
|
|
322
|
-
|
|
323
|
-
return auth.hasPermission(moduleStr as UserModule, ...permissionLevels)
|
|
316
|
+
return auth.hasPermission(moduleStr as UserModule, permission)
|
|
317
|
+
})
|
|
324
318
|
}
|
|
325
319
|
|
|
326
320
|
// Recursively filter children
|
|
@@ -5,6 +5,8 @@ export enum Permission {
|
|
|
5
5
|
NONE = 'NONE',
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
export type AccessPermission = Permission | string
|
|
9
|
+
|
|
8
10
|
export const PERMISSION_LABEL = {
|
|
9
11
|
[Permission.ADMIN]: 'Admin',
|
|
10
12
|
[Permission.USER]: 'User',
|
|
@@ -85,6 +87,7 @@ export interface IUserProfile {
|
|
|
85
87
|
export enum UserModule {
|
|
86
88
|
CHECKIN = 'clockin',
|
|
87
89
|
PMO = 'pmo',
|
|
90
|
+
PMO_TAB = 'pmo_tab',
|
|
88
91
|
TIMESHEET = 'timesheet',
|
|
89
92
|
SETTING = 'setting',
|
|
90
93
|
QUOTATION = 'quotation',
|
|
@@ -105,6 +108,7 @@ export enum UserModule {
|
|
|
105
108
|
export interface IUserAccessLevel {
|
|
106
109
|
used_id: string
|
|
107
110
|
pmo: Permission.USER | Permission.ADMIN | Permission.SUPER
|
|
111
|
+
pmo_tab?: string[]
|
|
108
112
|
clockin: Permission.USER | Permission.ADMIN
|
|
109
113
|
timesheet: Permission.USER | Permission.ADMIN | Permission.SUPER
|
|
110
114
|
setting: Permission.USER | Permission.SUPER
|
|
@@ -225,7 +229,7 @@ export const useAuth = () => {
|
|
|
225
229
|
me.set(null)
|
|
226
230
|
})
|
|
227
231
|
|
|
228
|
-
const hasPermission = (module: UserModule, ...permissions:
|
|
232
|
+
const hasPermission = (module: UserModule, ...permissions: AccessPermission[]) => {
|
|
229
233
|
const accessLevel = me.value?.access_level
|
|
230
234
|
|
|
231
235
|
if (!accessLevel) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineNuxtRouteMiddleware, useAuth, navigateTo, abortNavigation } from '#imports'
|
|
2
2
|
|
|
3
3
|
export interface AccessGuardOptions {
|
|
4
|
-
permissions?: `${UserModule}:${
|
|
4
|
+
permissions?: `${UserModule}:${string}`[]
|
|
5
5
|
redirectTo?: string
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
|
|
11
11
|
|
|
12
12
|
if (
|
|
13
13
|
options.permissions?.some((perm) => {
|
|
14
|
-
const [module, permission] = perm.split(':') as [UserModule,
|
|
14
|
+
const [module, permission] = perm.split(':') as [UserModule, string]
|
|
15
15
|
|
|
16
16
|
return auth.hasPermission(module, permission)
|
|
17
17
|
})
|