add user role hierearchy lookup and management function
This commit is contained in:
1 parent
35eba6897a
commit
bc58f6e08e
1 file changed
+11
@@ -1,6 +1,17 @@
|
||||
export const UserRoles = ["user", "admin", "superadmin", "demo"] as const;
|
||||
export type UserRole = (typeof UserRoles)[number];
|
||||
|
||||
export const RoleHierarchy: Record<UserRole, number> = {
|
||||
demo: 0,
|
||||
user: 1,
|
||||
admin: 2,
|
||||
superadmin: 3,
|
||||
};
|
||||
|
||||
export const canManageRole = (actorRole: UserRole, targetRole: UserRole): boolean => {
|
||||
return RoleHierarchy[actorRole] > RoleHierarchy[targetRole];
|
||||
};
|
||||
|
||||
export interface UserProfileImage {
|
||||
data?: Buffer;
|
||||
contentType?: string;
|
||||
|
||||
Reference in new issue
Block a user