This commit is contained in:
Andras Schmelczer 2026-02-15 09:48:30 +00:00
parent 128b3191e7
commit 03445188ea
54 changed files with 596953 additions and 3577 deletions

View file

@ -5,6 +5,8 @@ export interface AuthUser {
id: string;
email: string;
verified: boolean;
isAdmin: boolean;
subscription: string;
}
function recordToUser(record: { id: string; [key: string]: unknown }): AuthUser {
@ -15,6 +17,8 @@ function recordToUser(record: { id: string; [key: string]: unknown }): AuthUser
id: record.id,
email: record.email,
verified: typeof record.verified === 'boolean' ? record.verified : false,
isAdmin: typeof record.is_admin === 'boolean' ? record.is_admin : false,
subscription: typeof record.subscription === 'string' ? record.subscription : 'free',
};
}
@ -110,6 +114,11 @@ export function useAuth() {
}
}, []);
const refreshAuth = useCallback(async () => {
const result = await pb.collection('users').authRefresh();
setUser(recordToUser(result.record));
}, []);
const clearError = useCallback(() => {
setError(null);
}, []);
@ -123,6 +132,7 @@ export function useAuth() {
loginWithOAuth,
logout,
requestPasswordReset,
refreshAuth,
clearError,
};
}