fix and update
This commit is contained in:
@@ -29,11 +29,14 @@ import {
|
||||
resetGatewayCircuit,
|
||||
resetPinRequiredNotification,
|
||||
scheduleFedcmSessionSync,
|
||||
syncFedcmSession,
|
||||
setPinRequiredHandler,
|
||||
subscribeApiReady,
|
||||
subscribeApiNotReady,
|
||||
} from '@/lib/api';
|
||||
import { finalizeFedcmLogin, shouldFinalizeFedcmLogin } from '@/lib/fedcm-login-bridge';
|
||||
import { FedcmApiLoginStatusBridge } from './fedcm-api-login-status';
|
||||
import { usePublicSettings } from './public-settings-provider';
|
||||
import { useToast } from './toast-provider';
|
||||
import { PinLockModal } from './pin-lock-modal';
|
||||
import { AppBootstrapScreen } from './app-bootstrap-screen';
|
||||
@@ -123,6 +126,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const { showToast } = useToast();
|
||||
const { publicApiUrl } = usePublicSettings();
|
||||
const initialAuth = React.useMemo(() => readInitialAuthState(), []);
|
||||
const [token, setToken] = React.useState<string | null>(initialAuth.token);
|
||||
const [user, setUser] = React.useState<PublicUser | null>(null);
|
||||
@@ -258,6 +262,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
if (typeof window !== 'undefined' && shouldFinalizeFedcmLogin(window.location.pathname)) {
|
||||
void finalizeFedcmLogin(auth.accessToken);
|
||||
} else {
|
||||
void syncFedcmSession(auth.accessToken);
|
||||
scheduleFedcmSessionSync(auth.accessToken, 8000);
|
||||
}
|
||||
}
|
||||
@@ -751,6 +756,11 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
children
|
||||
)}
|
||||
<PinLockModal open={isPinLocked} isSubmitting={pinSubmitting} error={pinError} onSubmit={handlePinUnlock} />
|
||||
<FedcmApiLoginStatusBridge
|
||||
active={isSessionReady && hasStoredSession && !isPinLocked}
|
||||
accessToken={token}
|
||||
publicApiUrl={publicApiUrl}
|
||||
/>
|
||||
</AuthContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user