add user role hierearchy lookup and management function

This commit is contained in:
Alex Holliday committed 2026-02-04 17:48:58 +00:00
1 parent 35eba6897a
commit bc58f6e08e
1 file changed
+11
+11
View File
@@ -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;