短信验证调试成功
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
ensureSession,
|
||||
getDeviceKey,
|
||||
request,
|
||||
saveSession,
|
||||
type SessionPayload,
|
||||
type UserProfile,
|
||||
} from '../lib/api';
|
||||
@@ -21,6 +22,7 @@ type UserSessionContextValue = {
|
||||
ready: boolean;
|
||||
profile: UserProfile | null;
|
||||
phoneVerified: boolean;
|
||||
applySession: (session: SessionPayload) => void;
|
||||
refreshProfile: () => Promise<void>;
|
||||
resetSession: () => Promise<void>;
|
||||
};
|
||||
@@ -33,6 +35,7 @@ export function UserSessionProvider({ children }: { children: ReactNode }) {
|
||||
const [phoneVerified, setPhoneVerified] = useState(false);
|
||||
|
||||
const applySession = useCallback((session: SessionPayload) => {
|
||||
saveSession(session);
|
||||
if (session.user) setProfile(session.user);
|
||||
setPhoneVerified(!!session.phoneVerified || !!session.user?.phoneVerified);
|
||||
}, []);
|
||||
@@ -83,10 +86,11 @@ export function UserSessionProvider({ children }: { children: ReactNode }) {
|
||||
ready,
|
||||
profile,
|
||||
phoneVerified,
|
||||
applySession,
|
||||
refreshProfile,
|
||||
resetSession,
|
||||
}),
|
||||
[ready, profile, phoneVerified, refreshProfile, resetSession],
|
||||
[ready, profile, phoneVerified, applySession, refreshProfile, resetSession],
|
||||
);
|
||||
|
||||
if (!ready) {
|
||||
|
||||
Reference in New Issue
Block a user