Update auth endpoints to account for new JSON responses

This commit is contained in:
Andrew Kingston 2024-12-16 16:56:52 +00:00
parent 8c4bb89412
commit 4fd47b5908
No known key found for this signature in database
1 changed files with 9 additions and 4 deletions

View File

@ -1,17 +1,23 @@
import { import {
GetInitInfoResponse, GetInitInfoResponse,
LoginRequest, LoginRequest,
LoginResponse,
LogoutResponse, LogoutResponse,
PasswordResetRequest, PasswordResetRequest,
PasswordResetResponse, PasswordResetResponse,
PasswordResetUpdateRequest, PasswordResetUpdateRequest,
PasswordResetUpdateResponse, PasswordResetUpdateResponse,
SetInitInfoRequest, SetInitInfoRequest,
SetInitInfoResponse,
} from "@budibase/types" } from "@budibase/types"
import { BaseAPIClient } from "./types" import { BaseAPIClient } from "./types"
export interface AuthEndpoints { export interface AuthEndpoints {
logIn: (tenantId: string, username: string, password: string) => Promise<void> logIn: (
tenantId: string,
username: string,
password: string
) => Promise<LoginResponse>
logOut: () => Promise<LogoutResponse> logOut: () => Promise<LogoutResponse>
requestForgotPassword: ( requestForgotPassword: (
tenantId: string, tenantId: string,
@ -22,7 +28,7 @@ export interface AuthEndpoints {
password: string, password: string,
resetCode: string resetCode: string
) => Promise<PasswordResetUpdateResponse> ) => Promise<PasswordResetUpdateResponse>
setInitInfo: (info: SetInitInfoRequest) => Promise<void> setInitInfo: (info: SetInitInfoRequest) => Promise<SetInitInfoResponse>
getInitInfo: () => Promise<GetInitInfoResponse> getInitInfo: () => Promise<GetInitInfoResponse>
} }
@ -34,13 +40,12 @@ export const buildAuthEndpoints = (API: BaseAPIClient): AuthEndpoints => ({
* @param password the password * @param password the password
*/ */
logIn: async (tenantId, username, password) => { logIn: async (tenantId, username, password) => {
return await API.post<LoginRequest>({ return await API.post<LoginRequest, LoginResponse>({
url: `/api/global/auth/${tenantId}/login`, url: `/api/global/auth/${tenantId}/login`,
body: { body: {
username, username,
password, password,
}, },
parseResponse: () => undefined,
}) })
}, },