diff options
Diffstat (limited to 'api/client.ts')
| -rw-r--r-- | api/client.ts | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/api/client.ts b/api/client.ts index 703b1f0..63aa525 100644 --- a/api/client.ts +++ b/api/client.ts @@ -136,9 +136,45 @@ class ApiClient { return result; } + async signInWithGoogle( + idToken: string, + ): Promise<{ success: boolean; token?: string; reason?: string }> { + const result = await this.post<{ + success: boolean; + token: string; + reason: string; + }>("/signin/google", { + idToken, + }); + + if (result.success && result.token) { + await this.setToken(result.token); + } + + return result; + } + async signOut() { await this.clearToken(); } + + async requestPasswordReset( + email: string, + ): Promise<{ success: boolean; reason: string }> { + return this.post<{ success: boolean; reason: string }>("/resetpassword", { + email, + }); + } + + async confirmPasswordReset( + token: string, + password: string, + ): Promise<{ success: boolean; reason: string }> { + return this.post<{ success: boolean; reason: string }>("/resetpassword", { + token, + password, + }); + } } export const apiClient = new ApiClient(); |