feat: implement terminal authentication bootstrap and integrate into ScanTerminalDashboard

This commit is contained in:
2569718930@qq.com
2026-05-30 00:05:19 +08:00
parent b3a63aa9af
commit c26f89f134
5 changed files with 261 additions and 7 deletions
@@ -55,6 +55,7 @@ import {
mergeAccessStateWithAuthPayload,
type AuthProfilePayload,
} from "@/components/dashboard/scan-terminal/terminal-access-state";
import { loadTerminalAuthProfile } from "@/components/dashboard/scan-terminal/terminal-auth-bootstrap";
import {
cityListItemsToScanRows,
mergeScanRowsWithCityFallbackRows,
@@ -1034,12 +1035,15 @@ function ScanTerminalScreen() {
cancelled = true;
};
}
const sessionPromise = hasSupabasePublicEnv()
? getSupabaseBrowserClient().auth.getSession()
: Promise.resolve({ data: { session: null } });
sessionPromise
.then(({ data: { session } }) => loadAuthProfile(session?.access_token))
const supabaseEnabled = hasSupabasePublicEnv();
loadTerminalAuthProfile({
getSession: () =>
supabaseEnabled
? getSupabaseBrowserClient().auth.getSession()
: Promise.resolve({ data: { session: null } }),
hasSupabasePublicEnv: supabaseEnabled,
loadAuthProfile,
})
.then((payload) => {
if (cancelled) return;
setProAccess((prev) => mergeAccessStateWithAuthPayload(prev, payload));