first time setup E2E
This commit is contained in:
parent
ba2d72b205
commit
fd2e2c0415
|
@ -0,0 +1,35 @@
|
||||||
|
<script>
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
import { goto } from "@roxi/routify"
|
||||||
|
import {
|
||||||
|
SideNavigation as Navigation,
|
||||||
|
SideNavigationItem as Item,
|
||||||
|
} from "@budibase/bbui"
|
||||||
|
import { auth } from "stores/backend"
|
||||||
|
import LoginForm from "components/login/LoginForm.svelte"
|
||||||
|
import BuilderSettingsButton from "components/start/BuilderSettingsButton.svelte"
|
||||||
|
import LogoutButton from "components/start/LogoutButton.svelte"
|
||||||
|
import Logo from "/assets/budibase-logo.svg"
|
||||||
|
import api from "builderStore/api"
|
||||||
|
|
||||||
|
let modal
|
||||||
|
let checklist
|
||||||
|
|
||||||
|
async function fetchConfigChecklist() {
|
||||||
|
const response = await api.get("/api/admin/configs/checklist")
|
||||||
|
return await response.json()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
const response = await fetchConfigChecklist()
|
||||||
|
if (!response.adminUser) {
|
||||||
|
$goto("./admin")
|
||||||
|
}
|
||||||
|
|
||||||
|
checklist = response
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if checklist}
|
||||||
|
<slot />
|
||||||
|
{/if}
|
|
@ -8,26 +8,21 @@
|
||||||
Input,
|
Input,
|
||||||
Body,
|
Body,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
|
import { goto } from "@roxi/routify"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
import api from "builderStore/api"
|
import api from "builderStore/api"
|
||||||
|
|
||||||
let adminUser = {}
|
let adminUser = {}
|
||||||
|
|
||||||
async function save(doc) {
|
async function save() {
|
||||||
try {
|
try {
|
||||||
// Save the admin user
|
// Save the admin user
|
||||||
const response = await api.post(`/api/admin/users`, {
|
const response = await api.post(`/api/admin/users/init`, adminUser)
|
||||||
email: adminUser.email,
|
|
||||||
password: adminUser.password,
|
|
||||||
roles: {},
|
|
||||||
admin: {
|
|
||||||
global: true,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
if (response.status !== 200) throw new Error(json.message)
|
if (response.status !== 200) throw new Error(json.message)
|
||||||
notifications.success(`Admin user created.`)
|
notifications.success(`Admin user created.`)
|
||||||
|
$goto("../portal")
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notifications.error(`Failed to create admin user.`)
|
notifications.error(`Failed to create admin user.`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
SideNavigation as Navigation,
|
SideNavigation as Navigation,
|
||||||
SideNavigationItem as Item,
|
SideNavigationItem as Item,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
|
import api from "builderStore/api"
|
||||||
|
|
||||||
let orgName
|
let orgName
|
||||||
let orgLogo
|
let orgLogo
|
||||||
|
@ -22,12 +23,8 @@
|
||||||
orgLogo = "https://via.placeholder.com/150"
|
orgLogo = "https://via.placeholder.com/150"
|
||||||
|
|
||||||
// set onBoardingProgress
|
// set onBoardingProgress
|
||||||
onBoardingProgress = 20
|
|
||||||
user = { name: "John Doe" }
|
|
||||||
|
|
||||||
if (onBoardingProgress < 21) {
|
user = { name: "John Doe" }
|
||||||
$goto("../admin")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(getInfo)
|
onMount(getInfo)
|
||||||
|
|
|
@ -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 = {
|
ctx.request.body = {
|
||||||
email: FIRST_USER_EMAIL,
|
email: email,
|
||||||
password: FIRST_USER_PASSWORD,
|
password: password,
|
||||||
roles: {},
|
roles: {},
|
||||||
builder: {
|
builder: {
|
||||||
global: true,
|
global: true,
|
||||||
},
|
},
|
||||||
|
admin: {
|
||||||
|
global: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
await exports.save(ctx)
|
await exports.save(ctx)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@ const { routes } = require("./routes")
|
||||||
const { buildAuthMiddleware } = require("@budibase/auth").auth
|
const { buildAuthMiddleware } = require("@budibase/auth").auth
|
||||||
|
|
||||||
const NO_AUTH_ENDPOINTS = [
|
const NO_AUTH_ENDPOINTS = [
|
||||||
"/api/admin/users/first",
|
"/api/admin/users/init",
|
||||||
|
"/api/admin/configs/checklist",
|
||||||
"/api/admin/auth",
|
"/api/admin/auth",
|
||||||
"/api/admin/auth/google",
|
"/api/admin/auth/google",
|
||||||
"/api/admin/auth/google/callback",
|
"/api/admin/auth/google/callback",
|
||||||
|
|
|
@ -27,7 +27,7 @@ function buildUserSaveValidation() {
|
||||||
router
|
router
|
||||||
.post("/api/admin/users", buildUserSaveValidation(), controller.save)
|
.post("/api/admin/users", buildUserSaveValidation(), controller.save)
|
||||||
.get("/api/admin/users", controller.fetch)
|
.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)
|
.delete("/api/admin/users/:id", controller.destroy)
|
||||||
.get("/api/admin/users/:id", controller.find)
|
.get("/api/admin/users/:id", controller.find)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue