Files
cameleer-server/ui/src/api/queries/auth.ts
hsiegeln 448a63adc9
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m48s
CI / docker (push) Successful in 1m45s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 37s
feat: add About Me dialog showing user info, roles, and groups
- Add GET /api/v1/auth/me endpoint returning current user's UserDetail
- Add AboutMeDialog component with role badges and group memberships
- Add userMenuItems prop to TopBar via design-system update
- Wire "About Me" menu item into user dropdown above Logout

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 12:12:29 +02:00

49 lines
1.1 KiB
TypeScript

import { useQuery } from '@tanstack/react-query';
import { config } from '../../config';
import { useAuthStore } from '../../auth/auth-store';
export interface RoleSummary {
id: string;
name: string;
system: boolean;
source: string;
}
export interface GroupSummary {
id: string;
name: string;
}
export interface UserDetail {
userId: string;
provider: string;
email: string;
displayName: string;
createdAt: string;
directRoles: RoleSummary[];
directGroups: GroupSummary[];
effectiveRoles: RoleSummary[];
effectiveGroups: GroupSummary[];
}
async function fetchMe(): Promise<UserDetail> {
const token = useAuthStore.getState().accessToken;
const res = await fetch(`${config.apiBaseUrl}/auth/me`, {
headers: {
...(token ? { Authorization: `Bearer ${token}` } : {}),
'X-Cameleer-Protocol-Version': '1',
},
});
if (!res.ok) throw new Error(`API error: ${res.status}`);
return res.json();
}
export function useMe(enabled = false) {
return useQuery({
queryKey: ['auth', 'me'],
queryFn: fetchMe,
enabled,
staleTime: 30_000,
});
}