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