fix: Electron login issues
This commit is contained in:
@@ -159,7 +159,8 @@ export function Dashboard({
|
||||
setDbHealth("error");
|
||||
}
|
||||
|
||||
const hosts = await getSSHHosts();
|
||||
const hostsResponse = await getSSHHosts();
|
||||
const hosts = Array.isArray(hostsResponse) ? hostsResponse : [];
|
||||
setTotalServers(hosts.length);
|
||||
|
||||
let totalTunnelsCount = 0;
|
||||
@@ -177,11 +178,17 @@ export function Dashboard({
|
||||
}
|
||||
setTotalTunnels(totalTunnelsCount);
|
||||
|
||||
const credentials = await getCredentials();
|
||||
const credentialsResponse = await getCredentials();
|
||||
const credentials = Array.isArray(credentialsResponse)
|
||||
? credentialsResponse
|
||||
: [];
|
||||
setTotalCredentials(credentials.length);
|
||||
|
||||
setRecentActivityLoading(true);
|
||||
const activity = await getRecentActivity(35);
|
||||
const activityResponse = await getRecentActivity(35);
|
||||
const activity = Array.isArray(activityResponse)
|
||||
? activityResponse
|
||||
: [];
|
||||
setRecentActivity(activity);
|
||||
setRecentActivityLoading(false);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Button } from "@/components/ui/button.tsx";
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert.tsx";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AlertCircle, Loader2, ArrowLeft, RefreshCw } from "lucide-react";
|
||||
import { getCookie } from "@/ui/main-axios.ts";
|
||||
import { getCookie, getUserInfo } from "@/ui/main-axios.ts";
|
||||
|
||||
interface ElectronLoginFormProps {
|
||||
serverUrl: string;
|
||||
@@ -53,11 +53,22 @@ export function ElectronLoginForm({
|
||||
throw new Error("Failed to save JWT to localStorage");
|
||||
}
|
||||
|
||||
try {
|
||||
await getUserInfo();
|
||||
} catch (verifyErr) {
|
||||
localStorage.removeItem("jwt");
|
||||
throw new Error("Invalid or expired authentication token");
|
||||
}
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
|
||||
onAuthSuccess();
|
||||
} catch (err) {
|
||||
setError(t("errors.authTokenSaveFailed"));
|
||||
const errorMessage =
|
||||
err instanceof Error
|
||||
? err.message
|
||||
: t("errors.authTokenSaveFailed");
|
||||
setError(errorMessage);
|
||||
setIsAuthenticating(false);
|
||||
hasAuthenticatedRef.current = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user