feat(api): add auth guards

This commit is contained in:
dahyeon committed 2026-04-12 22:17:00 +09:00
1 parent 3a86676a12
commit d4b790fd86
16 files changed
+592

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import { CommunityRole } from '../global/database/schema';
export type Permission =
| 'community:edit'
| 'community:delete'
| 'community:transfer'
| 'user:role:manage'
| 'match:create'
| 'match:edit'
| 'match:delete'
| 'auction:manage';
type PermissionSet = readonly Permission[] | readonly ['*'];
export const ROLE_PERMISSIONS: Record<CommunityRole, PermissionSet> = {
owner: ['*'] as const,
admin: [
'community:edit',
'user:role:manage',
'match:create',
'match:edit',
'match:delete',
'auction:manage',
] as const,
member: [] as const,
};
export function roleHasPermission(
role: CommunityRole,
permission: Permission,
): boolean {
const perms = ROLE_PERMISSIONS[role];
if (perms.length === 1 && perms[0] === '*') return true;
return (perms as readonly Permission[]).includes(permission);
}