1
0
Fork 0
mirror of synced 2024-07-03 21:40:55 +12:00

Auth flow

This commit is contained in:
Pedro Silva 2023-02-24 09:46:05 +00:00
parent 9474d24908
commit 655b235b76
3 changed files with 10 additions and 5 deletions

View file

@ -23,6 +23,7 @@ class PublicAPIClient {
)
}
this.host = `${env.BUDIBASE_HOST}/api/public/v1`
this.appId = appId
}
@ -32,6 +33,8 @@ class PublicAPIClient {
setApiKey(apiKey: string) {
this.apiKey = apiKey
process.env.BUDIBASE_PUBLIC_API_KEY = apiKey
this.host = `${env.BUDIBASE_HOST}/api/public/v1`
}
apiCall =

View file

@ -1,16 +1,16 @@
import { Response } from "node-fetch"
import PublicAPIClient from "./PublicAPIClient"
import AccountsAPIClient from "./accountsAPIClient"
import { ApiKeyResponse } from "../fixtures/types/apiKeyResponse"
export default class AuthApi {
api: PublicAPIClient
api: AccountsAPIClient
constructor(apiClient: PublicAPIClient) {
constructor(apiClient: AccountsAPIClient) {
this.api = apiClient
}
async loginAsAdmin(): Promise<[Response, any]> {
const response = await this.api.post(`/global/auth/default/login`, {
const response = await this.api.post(`/auth/login`, {
body: {
username: process.env.BB_ADMIN_USER_EMAIL,
password: process.env.BB_ADMIN_USER_PASSWORD,
@ -22,7 +22,7 @@ export default class AuthApi {
}
async login(email: String, password: String): Promise<[Response, any]> {
const response = await this.api.post(`/global/auth/default/login`, {
const response = await this.api.post(`/auth/login`, {
body: {
username: email,
password: password,

View file

@ -11,6 +11,8 @@ describe("Public API - /users endpoints", () => {
beforeAll(async () => {
await config.beforeAll()
await config.setupAccountAndTenant()
await config.setApiKey()
const [_, user] = await config.users.seed()
config.context = user
})