1
0
Fork 0
mirror of synced 2024-06-20 19:30:28 +12:00

working through auth - adding user instance map

This commit is contained in:
Martin McKeaveney 2020-05-04 18:07:03 +01:00
parent c3f68e9895
commit 2afd1cd4dd
6 changed files with 16 additions and 6 deletions

View file

@ -1,7 +1,7 @@
import { filter, cloneDeep, values } from "lodash/fp"
import { pipe } from "components/common/core"
import * as backendStoreActions from "./backend"
import { writable } from "svelte/store"
import { writable, get } from "svelte/store"
import api from "../api"
import {
DEFAULT_PAGES_OBJECT

View file

@ -8,7 +8,7 @@
// It's a screen, set it to that screen
if ($params.screen !== "page-layout") {
store.setCurrentScreen($params.screen)
store.setCurrentScreen(decodeURI($params.screen))
// There are leftover stuff, like IDs, so navigate the components and find the ID and select it.
if ($leftover) {
@ -30,6 +30,7 @@
// Find Component with ID and continue
function findComponent(ids, children) {
console.log(ids, children);
// Setup stuff
let componentToSelect
let currentChildren = children

View file

@ -8,8 +8,7 @@
import PagesList from "components/userInterface/PagesList.svelte"
import IconButton from "components/common/IconButton.svelte"
import NewScreen from "components/userInterface/NewScreen.svelte"
import CurrentItemPreview from "components/userInterface/CurrentItemPreview.svelte"
import SettingsView from "components/userInterface/SettingsView.svelte"
import CurrentItemPreview from "components/userInterface/AppPreview"
import PageView from "components/userInterface/PageView.svelte"
import ComponentsPaneSwitcher from "components/userInterface/ComponentsPaneSwitcher.svelte"
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
@ -104,7 +103,6 @@
</div>
<NewScreen bind:this={newScreenPicker} />
<SettingsView bind:this={settingsView} />
<ConfirmDialog
bind:this={confirmDeleteDialog}

View file

@ -24,6 +24,7 @@ exports.create = async function(ctx) {
const { id, rev } = await clientDb.post({
type: "app",
instances: [],
userInstanceMap: {},
componentLibraries: [
"@budibase/standard-components",
"@budibase/materialdesign-components"

View file

@ -24,6 +24,16 @@ exports.create = async function(ctx) {
type: "user"
});
// the clientDB needs to store a map of users against the app
const clientDB = new CouchDB(process.env.CLIENT_ID);
const app = await clientDB.get(ctx.params.appId);
app.userInstanceMap = {
...app.userInstanceMap,
[response._id]: ctx.params.instanceId
}
await clientDb.put(app);
ctx.body = {
user: {
id: response.id,

View file

@ -5,7 +5,7 @@ const router = Router();
router
.get("/api/:instanceId/users", controller.fetch)
.post("/api/:instanceId/users", controller.create)
.post("/api/:appId/:instanceId/users", controller.create)
.delete("/api/:instanceId/users/:userId", controller.destroy);
module.exports = router;