Auth flow
This commit is contained in:
parent
9474d24908
commit
655b235b76
|
@ -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 =
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue