From ac73b5c4aae2251ed5b56dc908045655fb6d68d4 Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Tue, 3 Nov 2020 13:45:49 +0000 Subject: [PATCH] Further work towards the re-implementation of auth, changing how the appId is determined, now it mainly will use a header, and a cookie which will be written to store the current status of appId. --- packages/builder/src/builderStore/api.js | 8 ++-- .../src/pages/[application]/_reset.svelte | 2 - packages/client/src/api/index.js | 11 +++-- packages/server/src/api/controllers/auth.js | 14 ++----- .../server/src/middleware/authenticated.js | 19 +++++---- .../src/utilities/builder/setBuilderToken.js | 14 ++----- packages/server/src/utilities/index.js | 42 +++++++++++++++---- packages/standard-components/src/api.js | 4 ++ 8 files changed, 67 insertions(+), 47 deletions(-) diff --git a/packages/builder/src/builderStore/api.js b/packages/builder/src/builderStore/api.js index a33a695028..46304e1486 100644 --- a/packages/builder/src/builderStore/api.js +++ b/packages/builder/src/builderStore/api.js @@ -1,15 +1,17 @@ +import { store } from "./index" +import { get as svelteGet } from "svelte/store" + const apiCall = method => async ( url, body, headers = { "Content-Type": "application/json" } ) => { - const response = await fetch(url, { + headers["x-budibase-app-id"] = svelteGet(store).appId + return await fetch(url, { method: method, body: body && JSON.stringify(body), headers, }) - - return response } export const post = apiCall("POST") diff --git a/packages/builder/src/pages/[application]/_reset.svelte b/packages/builder/src/pages/[application]/_reset.svelte index 06942e03c8..2dd672586f 100644 --- a/packages/builder/src/pages/[application]/_reset.svelte +++ b/packages/builder/src/pages/[application]/_reset.svelte @@ -84,8 +84,6 @@