You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

50 lines
1.2 KiB

import httpClient from '../lib/httpClient'
import {
GoogleLoginRequestPayload,
LoginRequestPayload,
LoginResponse,
RegisterRequestPayload,
RegisterResponse,
} from './types'
class AuthService {
async login(payload: LoginRequestPayload): Promise<LoginResponse> {
const res = await httpClient.post(`/auth/login`, payload)
return res.data.data
}
async loginWithGoogle(
payload: GoogleLoginRequestPayload
): Promise<LoginResponse> {
const res = await httpClient.post(`/auth/google-login`, payload)
return res.data.data
}
async register(payload: RegisterRequestPayload): Promise<RegisterResponse> {
const res = await httpClient.post(`/auth/register`, payload)
return res.data.data
}
async getCurrentUser() {
const res = await httpClient.get(`/auth/who-am-i`)
return res.data.data
}
async requestPasswordReset({ email }) {
const res = await httpClient.post(`/auth/request-password-reset`, {
email,
})
return res.data.data
}
async resetPassword({ email, otp, newPassword }) {
const res = await httpClient.post(`/auth/reset-password`, {
email,
otp,
newPassword,
})
return res.data.data
}
}
export const authService = new AuthService()