diff options
| author | JustZvan <justzvan@justzvan.xyz> | 2026-04-06 15:32:51 +0200 |
|---|---|---|
| committer | JustZvan <justzvan@justzvan.xyz> | 2026-04-06 15:32:51 +0200 |
| commit | 3273e7a0fbbce82f4ce6cacbcdb7b6d6848f6c1b (patch) | |
| tree | 7662ab528c950e5b3605d3f134dc89f399417c8d /lib/auth.tsx | |
| parent | 7eb8ccae48b0cc18a9dcaa9c3626a02df8e6d919 (diff) | |
feat: gallery scanning preferences
Diffstat (limited to 'lib/auth.tsx')
| -rw-r--r-- | lib/auth.tsx | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/auth.tsx b/lib/auth.tsx index b05c6a7..ac394f4 100644 --- a/lib/auth.tsx +++ b/lib/auth.tsx @@ -1,9 +1,9 @@ import { - createContext, - ReactNode, - useContext, - useEffect, - useState, + createContext, + ReactNode, + useContext, + useEffect, + useState, } from "react"; import { apiClient } from "../api/client"; @@ -17,6 +17,9 @@ type AuthContextType = AuthState & { email: string, password: string, ) => Promise<{ success: boolean; reason?: string }>; + signInWithGoogle: ( + idToken: string, + ) => Promise<{ success: boolean; reason?: string }>; signUp: ( email: string, password: string, @@ -60,13 +63,23 @@ export function AuthProvider({ children }: { children: ReactNode }) { return { success: result.success, reason: result.reason }; }; + const signInWithGoogle = async (idToken: string) => { + const result = await apiClient.signInWithGoogle(idToken); + if (result.success) { + setState({ isLoading: false, isAuthenticated: true }); + } + return { success: result.success, reason: result.reason }; + }; + const signOut = async () => { await apiClient.signOut(); setState({ isLoading: false, isAuthenticated: false }); }; return ( - <AuthContext.Provider value={{ ...state, signIn, signUp, signOut }}> + <AuthContext.Provider + value={{ ...state, signIn, signInWithGoogle, signUp, signOut }} + > {children} </AuthContext.Provider> ); |