feat: rewrite frontend auth — roles from org store, Logto org role names
Replace ID-token claim reads with org store lookups in useAuth and usePermissions; add currentOrgRoles to useOrgStore; update role names to Logto org role conventions (admin/member); remove username from Layout (no longer derived from token claims). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
import { useAuth } from '../auth/useAuth';
|
||||
import { useOrgStore } from '../auth/useOrganization';
|
||||
|
||||
const ROLE_PERMISSIONS: Record<string, string[]> = {
|
||||
OWNER: ['tenant:manage', 'billing:manage', 'team:manage', 'apps:manage', 'apps:deploy', 'secrets:manage', 'observe:read', 'observe:debug', 'settings:manage'],
|
||||
ADMIN: ['team:manage', 'apps:manage', 'apps:deploy', 'secrets:manage', 'observe:read', 'observe:debug', 'settings:manage'],
|
||||
DEVELOPER: ['apps:deploy', 'secrets:manage', 'observe:read', 'observe:debug'],
|
||||
VIEWER: ['observe:read'],
|
||||
'admin': [
|
||||
'tenant:manage', 'billing:manage', 'team:manage', 'apps:manage',
|
||||
'apps:deploy', 'secrets:manage', 'observe:read', 'observe:debug',
|
||||
'settings:manage',
|
||||
],
|
||||
'member': ['apps:deploy', 'observe:read', 'observe:debug'],
|
||||
};
|
||||
|
||||
export function usePermissions() {
|
||||
const { roles } = useAuth();
|
||||
const { currentOrgRoles } = useOrgStore();
|
||||
const roles = currentOrgRoles ?? [];
|
||||
|
||||
const permissions = new Set<string>();
|
||||
for (const role of roles) {
|
||||
|
||||
Reference in New Issue
Block a user