mirror of
https://github.com/docmost/docmost.git
synced 2025-11-17 07:31:10 +10:00
frontend permissions
* rework backend workspace permissions
This commit is contained in:
19
apps/client/src/hooks/use-user-role.tsx
Normal file
19
apps/client/src/hooks/use-user-role.tsx
Normal file
@ -0,0 +1,19 @@
|
||||
import { useAtom } from "jotai";
|
||||
import { UserRole } from "@/lib/types.ts";
|
||||
import { currentUserAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
|
||||
export const useUserRole = () => {
|
||||
const [currentUser] = useAtom(currentUserAtom);
|
||||
|
||||
const isAdmin =
|
||||
currentUser?.user?.role === UserRole.ADMIN ||
|
||||
currentUser?.user?.role === UserRole.OWNER;
|
||||
|
||||
const isOwner = currentUser?.user?.role === UserRole.OWNER;
|
||||
|
||||
const isMember = currentUser?.user?.role === UserRole.MEMBER;
|
||||
|
||||
return { isAdmin, isOwner, isMember };
|
||||
};
|
||||
|
||||
export default useUserRole;
|
||||
Reference in New Issue
Block a user