fix and update

This commit is contained in:
lendry
2026-06-30 23:43:49 +03:00
parent 4b2ade9354
commit deb213bd77
6 changed files with 60 additions and 29 deletions

View File

@@ -56,6 +56,7 @@ interface AuthContextValue {
verifyTotpLogin: (totpChallengeToken: string, code: string) => Promise<AuthTokens>;
completePin: (sessionId: string, pin: string) => Promise<void>;
applyLoginAuth: (auth: AuthTokens) => Promise<AuthTokens>;
applyUserPatch: (patch: Partial<PublicUser>) => void;
register: (data: { displayName: string; login: string; password: string }) => Promise<void>;
refreshProfile: () => Promise<void>;
logout: () => void;
@@ -273,6 +274,15 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
router.push('/auth/login');
}, [clearPinLock, router]);
const applyUserPatch = React.useCallback((patch: Partial<PublicUser>) => {
setUser((current) => {
if (!current) return current;
const next = { ...current, ...patch };
cacheUserProfile(next);
return next;
});
}, []);
const refreshProfile = React.useCallback(async () => {
if (refreshInFlightRef.current) {
return refreshInFlightRef.current;
@@ -691,6 +701,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
verifyTotpLogin,
completePin,
applyLoginAuth,
applyUserPatch,
register,
refreshProfile,
logout