main
ts 28 lines 889 Bytes
Raw
1 import type { AuthResponse } from "@/types/auth"
2 import type { CommonResponse } from "@/types/common"
3 import { HttpClient } from "../httpClient"
4
5 export interface LoginPayload {
6 username: string
7 password: string
8 }
9
10 export default {
11 /** Authenticate user with local username/password */
12 login(payload: LoginPayload) {
13 return HttpClient.postForm<CommonResponse<AuthResponse>>("/auth/token/customer-portal", payload)
14 },
15
16 /** Refresh access token using the application refresh token (non-Keycloak) */
17 refresh(refreshToken: string) {
18 return HttpClient.post<CommonResponse<AuthResponse>>("/auth/refresh", { refresh_token: refreshToken })
19 },
20
21 resetPassword(username: string, newPassword: string, currentPassword: string) {
22 return HttpClient.post<CommonResponse>("/auth/reset-password/me", {
23 username,
24 current_password: currentPassword,
25 new_password: newPassword
26 })
27 }
28 }