fix reauth error handling and stale log messages

This commit is contained in:
CREDO23 2026-02-24 13:33:47 +02:00
parent 45b784cda6
commit 30ab464ba7
4 changed files with 21 additions and 5 deletions

View file

@ -12,6 +12,7 @@ import {
} from "lucide-react";
import { useParams } from "next/navigation";
import { useMemo, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import {
@ -426,10 +427,17 @@ function InsufficientPermissionsCard({ result }: { result: InsufficientPermissio
url.searchParams.set("space_id", searchSpaceId);
url.searchParams.set("return_url", window.location.pathname);
const response = await authenticatedFetch(url.toString());
if (!response.ok) {
const data = await response.json().catch(() => ({}));
toast.error(data.detail ?? "Failed to initiate re-authentication. Please try again.");
return;
}
const data = await response.json();
if (data.auth_url) {
window.location.href = data.auth_url;
}
} catch {
toast.error("Failed to initiate re-authentication. Please try again.");
} finally {
setLoading(false);
}