|
|
|
@ -24,7 +24,7 @@ const hasPermission = (role: Exclude<Roles, WorkspaceUserRoles>, hasRole: boolea
|
|
|
|
|
* * `allRoles` - all roles a user has (userRoles + baseRoles) |
|
|
|
|
* * `loadRoles` - a function to load reload user roles for scope |
|
|
|
|
*/ |
|
|
|
|
export const useRoles = createSharedComposable(() => { |
|
|
|
|
export const useRolesShared = createSharedComposable(() => { |
|
|
|
|
const { user } = useGlobal() |
|
|
|
|
|
|
|
|
|
const { api } = useApi() |
|
|
|
@ -172,9 +172,13 @@ export const useRoles = createSharedComposable(() => {
|
|
|
|
|
return { allRoles, orgRoles, workspaceRoles, baseRoles, loadRoles, isUIAllowed } |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
export const useRolesWrapper = () => { |
|
|
|
|
/** |
|
|
|
|
* Wrap the default shared composable to inject the current source if available |
|
|
|
|
* which will be used to determine if a user has permission to perform an action based on the source's restrictions |
|
|
|
|
*/ |
|
|
|
|
export const useRoles = () => { |
|
|
|
|
const currentSource = inject(ActiveSourceInj, ref()) |
|
|
|
|
const useRolesRes = useRoles() |
|
|
|
|
const useRolesRes = useRolesShared() |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
...useRolesRes, |
|
|
|
|