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:
@@ -24,7 +24,11 @@ type UserDisplayInfo = {
|
||||
const useResolveUserDisplay = (uuid: string | null | undefined) =>
|
||||
useQuery({
|
||||
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,
|
||||
retry: false,
|
||||
queryFn: async (): Promise<UserDisplayInfo | null> => {
|
||||
@@ -86,6 +90,12 @@ export function useUserDisplay(uuid: string | null | undefined): {
|
||||
if (!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 isMe = Boolean(currentSub) && currentSub === fullId
|
||||
if (isMe) {
|
||||
|
||||
Reference in New Issue
Block a user