fix mini app bot father
This commit is contained in:
@@ -26,6 +26,7 @@ import {
|
||||
} from '@/lib/api';
|
||||
import { useToast } from './toast-provider';
|
||||
import { PinLockModal } from './pin-lock-modal';
|
||||
import { EMBEDDED_AUTH_MESSAGE, type EmbeddedAuthPayload } from '@/lib/embedded-auth-bridge';
|
||||
|
||||
interface AuthContextValue {
|
||||
user: PublicUser | null;
|
||||
@@ -117,6 +118,19 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
resetPinRequiredNotification();
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
function handleEmbeddedAuth(event: Event) {
|
||||
const detail = (event as CustomEvent<EmbeddedAuthPayload>).detail;
|
||||
if (!detail?.token?.trim()) return;
|
||||
setToken(detail.token.trim());
|
||||
setHasStoredSession(true);
|
||||
clearPinLock();
|
||||
}
|
||||
|
||||
window.addEventListener(EMBEDDED_AUTH_MESSAGE, handleEmbeddedAuth as EventListener);
|
||||
return () => window.removeEventListener(EMBEDDED_AUTH_MESSAGE, handleEmbeddedAuth as EventListener);
|
||||
}, [clearPinLock]);
|
||||
|
||||
const activatePinLock = React.useCallback((sessionId: string) => {
|
||||
const resolvedSessionId = sessionId || window.localStorage.getItem(AUTH_SESSION_KEY);
|
||||
if (!resolvedSessionId) return;
|
||||
|
||||
Reference in New Issue
Block a user