refactor(desktop): AuthContext exposes userKeyState instead of device record
Replaces the per-device DeviceRecord lookup with a per-user discriminated union (loading | needs-setup | needs-unlock | unlocked). Heartbeat block deleted (telemetry no longer device-bound); webPush keyed by install-id.
This commit is contained in:
@@ -23,11 +23,14 @@ export function RequireAuth() {
|
||||
return <Outlet />;
|
||||
}
|
||||
|
||||
// Forces a registered device on this install. Sends to /device otherwise.
|
||||
// Forces a usable per-user encrypted key blob on this install. Sends to
|
||||
// /device (the setup/unlock page) when the blob is missing or locked.
|
||||
export function RequireDevice() {
|
||||
const { device, deviceLookupDone } = useAuth();
|
||||
if (!deviceLookupDone) return <FullScreenSpinner />;
|
||||
if (!device) return <Navigate to="/device" replace />;
|
||||
const { userKeyState } = useAuth();
|
||||
if (userKeyState.status === 'loading') return <FullScreenSpinner />;
|
||||
if (userKeyState.status === 'needs-setup' || userKeyState.status === 'needs-unlock') {
|
||||
return <Navigate to="/device" replace />;
|
||||
}
|
||||
return <Outlet />;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user