From 3080d0a8c4165b0d8ba0ea2faac0a9b06f73dba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Wed, 19 May 2021 11:23:14 +0200 Subject: [PATCH 01/27] adds UI elements for toggling builder access --- .../portal/manage/users/[userId].svelte | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/users/[userId].svelte b/packages/builder/src/pages/builder/portal/manage/users/[userId].svelte index b8c55d6aca..8968384c91 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/[userId].svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/[userId].svelte @@ -9,6 +9,8 @@ Divider, Label, Input, + Select, + Toggle, Modal, Table, ModalContent, @@ -33,23 +35,25 @@ $: appList = Object.keys($apps?.data).map(id => ({ ...$apps?.data?.[id], _id: id, - role: [$roleFetch?.data?.roles?.[id]], + role: [$userFetch?.data?.roles?.[id]], })) let selectedApp - const roleFetch = fetchData(`/api/admin/users/${userId}`) + const userFetch = fetchData(`/api/admin/users/${userId}`) const apps = fetchData(`/api/admin/roles`) async function deleteUser() { const res = await users.del(userId) if (res.message) { - notifications.success(`User ${$roleFetch?.data?.email} deleted.`) + notifications.success(`User ${$userFetch?.data?.email} deleted.`) $goto("./") } else { notifications.error("Failed to delete user.") } } + async function toggleBuilderAccess() {} + async function openUpdateRolesModal({ detail }) { console.log(detail) selectedApp = detail @@ -65,11 +69,10 @@
- User: {$roleFetch?.data?.email} + User: {$userFetch?.data?.email} Lorem ipsum dolor sit amet consectetur adipisicing elit. Debitis porro - ut nesciunt ipsam perspiciatis aliquam et hic minus alias beatae. Odit - veritatis quos quas laborum magnam tenetur perspiciatis ex hic. + >Change user settings and update their app roles. Also contains the + ability to delete the user as well as force reset their password.
@@ -79,7 +82,15 @@
- + +
+
+ + + From 5d60a0b1f667b2d6ec5e5a96c2e76e4cbdf52e83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Wed, 19 May 2021 13:57:54 +0200 Subject: [PATCH 08/27] wire up force reset password action --- .../builder/portal/manage/users/[userId].svelte | 12 +++++++++--- .../users/_components/ForceResetPasswordModal.svelte | 6 +++++- .../manage/users/_components/UpdateRolesModal.svelte | 1 - 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/users/[userId].svelte b/packages/builder/src/pages/builder/portal/manage/users/[userId].svelte index 1596577192..28d18b7047 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/[userId].svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/[userId].svelte @@ -108,8 +108,11 @@
- Regenerate passwordForce password reset
@@ -161,7 +164,10 @@ /> - + From f730900ed568c3e7a388584e2d4165c6f3a7486b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Thu, 20 May 2021 14:49:53 +0200 Subject: [PATCH 11/27] fix email templates being unreachable --- .../pages/builder/portal/manage/email/index.svelte | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/email/index.svelte b/packages/builder/src/pages/builder/portal/manage/email/index.svelte index 95fe0de40a..37d8af1bdd 100644 --- a/packages/builder/src/pages/builder/portal/manage/email/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/email/index.svelte @@ -1,29 +1,18 @@ - -
$goto("./")}> + + + +
+ $goto("./")} + quiet + size="S" + icon="BackAndroid" + > + Back to email settings + +
+ Email Template: {template} + Change the email template here. you can insert bindings (email, logo url, + etc.) from the list on the right +
diff --git a/packages/builder/src/pages/builder/portal/manage/email/index.svelte b/packages/builder/src/pages/builder/portal/manage/email/index.svelte index 37d8af1bdd..6b1036486b 100644 --- a/packages/builder/src/pages/builder/portal/manage/email/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/email/index.svelte @@ -5,6 +5,7 @@ Heading, Divider, Label, + Page, notifications, Layout, Input, @@ -91,69 +92,71 @@ }) - - - Email - - Sending email is not required, but highly recommended for processes such - as password recovery. To setup automated auth emails, simply add the - values below and click activate. - - - - {#if smtpConfig} - - SMTP - - To allow your app to benefit from automated auth emails, add your SMTP - details below. + + + + Email + + Sending email is not required, but highly recommended for processes such + as password recovery. To setup automated auth emails, simply add the + values below and click activate. - -
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- -
- - Templates - - Budibase comes out of the box with ready-made email templates to help - with user onboarding. Please refrain from changing the links. - - - $goto(`./${detail.purpose}`)} - allowEditRows={false} - allowSelectRows={false} - allowEditColumns={false} - /> - {/if} - + {#if smtpConfig} + + SMTP + + To allow your app to benefit from automated auth emails, add your SMTP + details below. + + + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+ + + Templates + + Budibase comes out of the box with ready-made email templates to help + with user onboarding. Please refrain from changing the links. + + +
$goto(`./${detail.purpose}`)} + allowEditRows={false} + allowSelectRows={false} + allowEditColumns={false} + /> + {/if} + + From 3d746b121711da4aab95e1c5fd2ff0fab2656ad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Thu, 20 May 2021 15:13:16 +0200 Subject: [PATCH 14/27] remove unused imports --- .../manage/email/_components/TemplateBindings.svelte | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/email/_components/TemplateBindings.svelte b/packages/builder/src/pages/builder/portal/manage/email/_components/TemplateBindings.svelte index bafa225d21..7b1b0fdd2f 100644 --- a/packages/builder/src/pages/builder/portal/manage/email/_components/TemplateBindings.svelte +++ b/packages/builder/src/pages/builder/portal/manage/email/_components/TemplateBindings.svelte @@ -1,12 +1,5 @@ + + diff --git a/packages/builder/src/pages/builder/portal/manage/email/index.svelte b/packages/builder/src/pages/builder/portal/manage/email/index.svelte index 6b1036486b..0e2e2e98fd 100644 --- a/packages/builder/src/pages/builder/portal/manage/email/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/email/index.svelte @@ -12,7 +12,6 @@ Body, Table, } from "@budibase/bbui" - import { onMount } from "svelte" import { email } from "stores/portal" import TemplateLink from "./_components/TemplateLink.svelte" import api from "builderStore/api" @@ -36,9 +35,6 @@ ] let smtpConfig - let bindingsOpen = false - let htmlModal - let htmlEditor let loading async function saveSmtp() { @@ -56,16 +52,8 @@ } } - async function saveTemplate() { - try { - await email.templates.save(selectedTemplate) - notifications.success(`Template saved.`) - } catch (err) { - notifications.error(`Failed to update template settings. ${err}`) - } - } - async function fetchSmtp() { + loading = true // fetch the configs for smtp const smtpResponse = await api.get(`/api/admin/configs/${ConfigTypes.SMTP}`) const smtpDoc = await smtpResponse.json() @@ -82,14 +70,10 @@ } else { smtpConfig = smtpDoc } + loading = false } - onMount(async () => { - loading = true - await fetchSmtp() - await email.templates.fetch() - loading = false - }) + fetchSmtp() From 1a4a13d43184c628150ae45891e4528decec095d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Thu, 20 May 2021 15:59:08 +0200 Subject: [PATCH 16/27] remove unused var --- .../src/pages/builder/portal/manage/email/[template].svelte | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/email/[template].svelte b/packages/builder/src/pages/builder/portal/manage/email/[template].svelte index 54b317a6f0..d48ba576d1 100644 --- a/packages/builder/src/pages/builder/portal/manage/email/[template].svelte +++ b/packages/builder/src/pages/builder/portal/manage/email/[template].svelte @@ -18,7 +18,6 @@ export let template - let selected = "Edit" let htmlEditor $: selectedTemplate = $email?.templates?.find( @@ -65,7 +64,7 @@ menu on the right. - +
Date: Thu, 20 May 2021 16:46:20 +0200 Subject: [PATCH 17/27] workaround to strange onMount bug with many Tabs components --- .../portal/manage/email/[template].svelte | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/email/[template].svelte b/packages/builder/src/pages/builder/portal/manage/email/[template].svelte index d48ba576d1..1ecaea693c 100644 --- a/packages/builder/src/pages/builder/portal/manage/email/[template].svelte +++ b/packages/builder/src/pages/builder/portal/manage/email/[template].svelte @@ -1,4 +1,5 @@ @@ -78,22 +83,24 @@ />
Bindings - - - - - - - - + {#if mounted} + + + + + + + + + {/if}
@@ -108,7 +115,7 @@ diff --git a/packages/builder/src/pages/builder/auth/reset.svelte b/packages/builder/src/pages/builder/auth/reset.svelte index 4cb949921c..5678cfab7a 100644 --- a/packages/builder/src/pages/builder/auth/reset.svelte +++ b/packages/builder/src/pages/builder/auth/reset.svelte @@ -1,5 +1,68 @@ - + + + From 8735ef088f40b9ff88e646fe66fc60b10dc5d04c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Fri, 21 May 2021 12:10:02 +0200 Subject: [PATCH 23/27] change forceReset bool name --- packages/worker/src/api/routes/admin/users.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/worker/src/api/routes/admin/users.js b/packages/worker/src/api/routes/admin/users.js index b44e95c3ce..1e7461fd26 100644 --- a/packages/worker/src/api/routes/admin/users.js +++ b/packages/worker/src/api/routes/admin/users.js @@ -10,7 +10,7 @@ function buildUserSaveValidation(isSelf = false) { let schema = { email: Joi.string().allow(null, ""), password: Joi.string().allow(null, ""), - forcePasswordChange: Joi.boolean().optional(), + forceResetPassword: Joi.boolean().optional(), firstName: Joi.string().allow(null, ""), lastName: Joi.string().allow(null, ""), builder: Joi.object({ From 090c54beb976b91fcd1c0c9369dbb8db8502c355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Fri, 21 May 2021 13:25:40 +0200 Subject: [PATCH 24/27] fix erroneous disable state in resetform --- .../builder/src/pages/builder/auth/reset.svelte | 14 +++++++++++--- packages/builder/src/stores/portal/auth.js | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/pages/builder/auth/reset.svelte b/packages/builder/src/pages/builder/auth/reset.svelte index 5678cfab7a..da7e2a7073 100644 --- a/packages/builder/src/pages/builder/auth/reset.svelte +++ b/packages/builder/src/pages/builder/auth/reset.svelte @@ -12,8 +12,11 @@ async function reset() { try { if (forceResetPassword) { - console.log("Updating self!") - await auth.updateSelf({ ...$auth.user, password }) + await auth.updateSelf({ + ...$auth.user, + password, + forceResetPassword: false, + }) $goto("../portal/") } else { await auth.resetPassword(password, resetCode) @@ -43,7 +46,12 @@ - + diff --git a/packages/builder/src/stores/portal/auth.js b/packages/builder/src/stores/portal/auth.js index c642a5708d..db94e2d01c 100644 --- a/packages/builder/src/stores/portal/auth.js +++ b/packages/builder/src/stores/portal/auth.js @@ -53,7 +53,7 @@ export function createAuthStore() { resetPassword: async (password, code) => { const response = await api.post(`/api/admin/auth/reset/update`, { password, - resetCode: code, + resetCode: code }) if (response.status !== 200) { throw "Unable to reset password" From 53f38f6f8f39351a43f53b47eee57ce3b0dbb638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Fri, 21 May 2021 13:26:55 +0200 Subject: [PATCH 25/27] move extracted components into page components --- .../src/components/login/ForgotForm.svelte | 62 -------------- .../src/components/login/LoginForm.svelte | 84 ------------------- .../builder/src/components/login/index.js | 1 - .../auth/_components}/GoogleButton.svelte | 0 .../src/pages/builder/auth/forgot.svelte | 61 +++++++++++++- .../src/pages/builder/auth/login.svelte | 83 +++++++++++++++++- 6 files changed, 140 insertions(+), 151 deletions(-) delete mode 100644 packages/builder/src/components/login/ForgotForm.svelte delete mode 100644 packages/builder/src/components/login/LoginForm.svelte delete mode 100644 packages/builder/src/components/login/index.js rename packages/builder/src/{components/login => pages/builder/auth/_components}/GoogleButton.svelte (100%) diff --git a/packages/builder/src/components/login/ForgotForm.svelte b/packages/builder/src/components/login/ForgotForm.svelte deleted file mode 100644 index f26c3bfc2b..0000000000 --- a/packages/builder/src/components/login/ForgotForm.svelte +++ /dev/null @@ -1,62 +0,0 @@ - - - - - diff --git a/packages/builder/src/components/login/LoginForm.svelte b/packages/builder/src/components/login/LoginForm.svelte deleted file mode 100644 index 1cba7976d7..0000000000 --- a/packages/builder/src/components/login/LoginForm.svelte +++ /dev/null @@ -1,84 +0,0 @@ - - - - - diff --git a/packages/builder/src/components/login/index.js b/packages/builder/src/components/login/index.js deleted file mode 100644 index 6a35637cea..0000000000 --- a/packages/builder/src/components/login/index.js +++ /dev/null @@ -1 +0,0 @@ -export { LoginForm } from "./LoginForm.svelte" diff --git a/packages/builder/src/components/login/GoogleButton.svelte b/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte similarity index 100% rename from packages/builder/src/components/login/GoogleButton.svelte rename to packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte diff --git a/packages/builder/src/pages/builder/auth/forgot.svelte b/packages/builder/src/pages/builder/auth/forgot.svelte index 59f048c4c3..f26c3bfc2b 100644 --- a/packages/builder/src/pages/builder/auth/forgot.svelte +++ b/packages/builder/src/pages/builder/auth/forgot.svelte @@ -1,5 +1,62 @@ - + + + diff --git a/packages/builder/src/pages/builder/auth/login.svelte b/packages/builder/src/pages/builder/auth/login.svelte index b3efe9c121..0f125604b2 100644 --- a/packages/builder/src/pages/builder/auth/login.svelte +++ b/packages/builder/src/pages/builder/auth/login.svelte @@ -1,5 +1,84 @@ - + + + From 9994c61f8f2a0292a6a8623984949ef453216b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Fri, 21 May 2021 13:33:05 +0200 Subject: [PATCH 26/27] fix login page --- packages/builder/src/pages/builder/auth/login.svelte | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/pages/builder/auth/login.svelte b/packages/builder/src/pages/builder/auth/login.svelte index 0f125604b2..076813b6e9 100644 --- a/packages/builder/src/pages/builder/auth/login.svelte +++ b/packages/builder/src/pages/builder/auth/login.svelte @@ -9,7 +9,7 @@ Layout, notifications, } from "@budibase/bbui" - import { goto } from "@roxi/routify" + import { goto, params } from "@roxi/routify" import { auth, organisation } from "stores/portal" import GoogleButton from "./_components/GoogleButton.svelte" @@ -26,7 +26,12 @@ if ($auth?.user?.forceResetPassword) { $goto("./reset") } else { - $goto("../portal") + if ($params["?returnUrl"]) { + window.location = decodeURIComponent($params["?returnUrl"]) + } else { + notifications.success("Logged in successfully") + $goto("../portal") + } } } catch (err) { console.error(err) From d51e1949fa81bc4fabc2ae35d90731d13d984c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Fri, 21 May 2021 13:43:27 +0200 Subject: [PATCH 27/27] lint fix --- packages/builder/src/stores/portal/auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/stores/portal/auth.js b/packages/builder/src/stores/portal/auth.js index db94e2d01c..c642a5708d 100644 --- a/packages/builder/src/stores/portal/auth.js +++ b/packages/builder/src/stores/portal/auth.js @@ -53,7 +53,7 @@ export function createAuthStore() { resetPassword: async (password, code) => { const response = await api.post(`/api/admin/auth/reset/update`, { password, - resetCode: code + resetCode: code, }) if (response.status !== 200) { throw "Unable to reset password"