From fd2e2c04155ced1d5f9a7455d82fa2e1d70788f6 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 5 May 2021 21:56:43 +0100 Subject: [PATCH] first time setup E2E --- packages/builder/src/pages/_layout.svelte | 35 +++++++++++++++++++ packages/builder/src/pages/admin/index.svelte | 13 +++---- .../builder/src/pages/portal/_layout.svelte | 7 ++-- .../worker/src/api/controllers/admin/users.js | 10 ++++-- packages/worker/src/api/index.js | 3 +- packages/worker/src/api/routes/admin/users.js | 2 +- 6 files changed, 51 insertions(+), 19 deletions(-) create mode 100644 packages/builder/src/pages/_layout.svelte diff --git a/packages/builder/src/pages/_layout.svelte b/packages/builder/src/pages/_layout.svelte new file mode 100644 index 0000000000..230d446165 --- /dev/null +++ b/packages/builder/src/pages/_layout.svelte @@ -0,0 +1,35 @@ + + +{#if checklist} + +{/if} diff --git a/packages/builder/src/pages/admin/index.svelte b/packages/builder/src/pages/admin/index.svelte index 37d8f8a767..f0d708602c 100644 --- a/packages/builder/src/pages/admin/index.svelte +++ b/packages/builder/src/pages/admin/index.svelte @@ -8,26 +8,21 @@ Input, Body, } from "@budibase/bbui" + import { goto } from "@roxi/routify" import { onMount } from "svelte" import api from "builderStore/api" let adminUser = {} - async function save(doc) { + async function save() { try { // Save the admin user - const response = await api.post(`/api/admin/users`, { - email: adminUser.email, - password: adminUser.password, - roles: {}, - admin: { - global: true, - }, - }) + const response = await api.post(`/api/admin/users/init`, adminUser) const json = await response.json() if (response.status !== 200) throw new Error(json.message) notifications.success(`Admin user created.`) + $goto("../portal") } catch (err) { notifications.error(`Failed to create admin user.`) } diff --git a/packages/builder/src/pages/portal/_layout.svelte b/packages/builder/src/pages/portal/_layout.svelte index a39b727fb3..2f6f650c21 100644 --- a/packages/builder/src/pages/portal/_layout.svelte +++ b/packages/builder/src/pages/portal/_layout.svelte @@ -10,6 +10,7 @@ SideNavigation as Navigation, SideNavigationItem as Item, } from "@budibase/bbui" + import api from "builderStore/api" let orgName let orgLogo @@ -22,12 +23,8 @@ orgLogo = "https://via.placeholder.com/150" // set onBoardingProgress - onBoardingProgress = 20 - user = { name: "John Doe" } - if (onBoardingProgress < 21) { - $goto("../admin") - } + user = { name: "John Doe" } } onMount(getInfo) diff --git a/packages/worker/src/api/controllers/admin/users.js b/packages/worker/src/api/controllers/admin/users.js index 146373e671..9d14861bb3 100644 --- a/packages/worker/src/api/controllers/admin/users.js +++ b/packages/worker/src/api/controllers/admin/users.js @@ -60,14 +60,18 @@ exports.save = async ctx => { } } -exports.firstUser = async ctx => { +exports.adminUser = async ctx => { + const { email, password } = ctx.request.body ctx.request.body = { - email: FIRST_USER_EMAIL, - password: FIRST_USER_PASSWORD, + email: email, + password: password, roles: {}, builder: { global: true, }, + admin: { + global: true, + }, } await exports.save(ctx) } diff --git a/packages/worker/src/api/index.js b/packages/worker/src/api/index.js index d0e60ffcd2..74e2df6493 100644 --- a/packages/worker/src/api/index.js +++ b/packages/worker/src/api/index.js @@ -5,7 +5,8 @@ const { routes } = require("./routes") const { buildAuthMiddleware } = require("@budibase/auth").auth const NO_AUTH_ENDPOINTS = [ - "/api/admin/users/first", + "/api/admin/users/init", + "/api/admin/configs/checklist", "/api/admin/auth", "/api/admin/auth/google", "/api/admin/auth/google/callback", diff --git a/packages/worker/src/api/routes/admin/users.js b/packages/worker/src/api/routes/admin/users.js index d4bc4b6b62..4e12a49038 100644 --- a/packages/worker/src/api/routes/admin/users.js +++ b/packages/worker/src/api/routes/admin/users.js @@ -27,7 +27,7 @@ function buildUserSaveValidation() { router .post("/api/admin/users", buildUserSaveValidation(), controller.save) .get("/api/admin/users", controller.fetch) - .post("/api/admin/users/first", controller.firstUser) + .post("/api/admin/users/init", controller.adminUser) .delete("/api/admin/users/:id", controller.destroy) .get("/api/admin/users/:id", controller.find)