Merge branch 'fix/user-display-skip-anonymous' into 'main'

fix(admin-ui): UserCell — не резолвить «anonymous» через display endpoint

See merge request 2-6/2-6-4/terravault/ordinis!266
This commit is contained in:
Александр Зимин
2026-05-25 15:34:58 +00:00
+11 -1
View File
@@ -24,7 +24,11 @@ type UserDisplayInfo = {
const useResolveUserDisplay = (uuid: string | null | undefined) => const useResolveUserDisplay = (uuid: string | null | undefined) =>
useQuery({ useQuery({
queryKey: ['user-display', uuid] as const, queryKey: ['user-display', uuid] as const,
enabled: Boolean(uuid), // Не дёргаем endpoint для литерала "anonymous" — это не UUID, а маркер
// отсутствия JWT subject (см. backend currentUserId fallback когда
// ORDINIS_AUTH_REQUIRED=false). Резолв даёт 404, в консоли мусор.
// Вместо запроса фронт сам подменит на «anonymous» в useUserDisplay ниже.
enabled: Boolean(uuid) && uuid !== 'anonymous',
staleTime: 5 * 60 * 1000, staleTime: 5 * 60 * 1000,
retry: false, retry: false,
queryFn: async (): Promise<UserDisplayInfo | null> => { queryFn: async (): Promise<UserDisplayInfo | null> => {
@@ -86,6 +90,12 @@ export function useUserDisplay(uuid: string | null | undefined): {
if (!fullId) { if (!fullId) {
return { display: 'anonymous', isMe: false, fullId: '' } return { display: 'anonymous', isMe: false, fullId: '' }
} }
// "anonymous" — литерал из backend currentUserId() когда нет JWT
// (ORDINIS_AUTH_REQUIRED=false и токен не дошёл). Не UUID, не резолвим
// через /admin/users/{sub}/display — там будет 404, шум в консоли.
if (fullId === 'anonymous') {
return { display: 'anonymous', isMe: false, fullId }
}
const currentSub = auth.user?.profile?.sub const currentSub = auth.user?.profile?.sub
const isMe = Boolean(currentSub) && currentSub === fullId const isMe = Boolean(currentSub) && currentSub === fullId
if (isMe) { if (isMe) {