feat: self-serve signup Phase 2 (frontend cutover) (#162)
Co-authored-by: Michael Chihlas <michael@resolutionflow.com> Co-committed-by: Michael Chihlas <michael@resolutionflow.com>
This commit was merged in pull request #162.
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import apiClient from './client'
|
||||
import type { Token, User, UserCreate, UserLogin, UserUpdate } from '@/types'
|
||||
|
||||
export interface OAuthCallbackResponse {
|
||||
access_token: string
|
||||
refresh_token: string
|
||||
token_type: string
|
||||
is_new_user: boolean
|
||||
}
|
||||
|
||||
export const authApi = {
|
||||
async register(data: UserCreate): Promise<User> {
|
||||
const response = await apiClient.post<User>('/auth/register', data)
|
||||
@@ -71,6 +78,36 @@ export const authApi = {
|
||||
async verifyEmail(token: string): Promise<void> {
|
||||
await apiClient.post('/auth/email/verify', { token })
|
||||
},
|
||||
|
||||
async googleCallback(
|
||||
code: string,
|
||||
options?: { accountInviteCode?: string; invitedEmail?: string },
|
||||
): Promise<OAuthCallbackResponse> {
|
||||
const response = await apiClient.post<OAuthCallbackResponse>(
|
||||
'/auth/google/callback',
|
||||
{
|
||||
code,
|
||||
account_invite_code: options?.accountInviteCode,
|
||||
invited_email: options?.invitedEmail,
|
||||
},
|
||||
)
|
||||
return response.data
|
||||
},
|
||||
|
||||
async microsoftCallback(
|
||||
code: string,
|
||||
options?: { accountInviteCode?: string; invitedEmail?: string },
|
||||
): Promise<OAuthCallbackResponse> {
|
||||
const response = await apiClient.post<OAuthCallbackResponse>(
|
||||
'/auth/microsoft/callback',
|
||||
{
|
||||
code,
|
||||
account_invite_code: options?.accountInviteCode,
|
||||
invited_email: options?.invitedEmail,
|
||||
},
|
||||
)
|
||||
return response.data
|
||||
},
|
||||
}
|
||||
|
||||
export default authApi
|
||||
|
||||
Reference in New Issue
Block a user