diff --git a/packages/bbui/src/Avatar/Avatar.svelte b/packages/bbui/src/Avatar/Avatar.svelte index f4e42b28a3..e23c2fc360 100644 --- a/packages/bbui/src/Avatar/Avatar.svelte +++ b/packages/bbui/src/Avatar/Avatar.svelte @@ -12,15 +12,7 @@ export let size = "M" export let url = "" export let disabled = false - export let name = "John Doe" - - function getInitials(name) { - let parts = name.split(" ") - if (parts.length > 0) { - return parts.map(name => name[0]).join("") - } - return name - } + export let initials = "JD" {#if url} @@ -38,7 +30,7 @@ size )}); font-size: calc(var({sizes.get(size)}) / 2)" > - {getInitials(name)} + {initials || ""} {/if} @@ -52,5 +44,6 @@ border-radius: 50%; overflow: hidden; user-select: none; + text-transform: uppercase; } diff --git a/packages/bbui/src/Form/Core/TextField.svelte b/packages/bbui/src/Form/Core/TextField.svelte index e1793c74a6..650aee4f82 100644 --- a/packages/bbui/src/Form/Core/TextField.svelte +++ b/packages/bbui/src/Form/Core/TextField.svelte @@ -82,6 +82,7 @@ on:blur on:focus on:input + on:keyup on:blur={onBlur} on:focus={onFocus} on:input={onInput} diff --git a/packages/bbui/src/Form/Input.svelte b/packages/bbui/src/Form/Input.svelte index fcab178182..1d98982b4f 100644 --- a/packages/bbui/src/Form/Input.svelte +++ b/packages/bbui/src/Form/Input.svelte @@ -34,5 +34,6 @@ on:input on:blur on:focus + on:keyup /> diff --git a/packages/builder/src/components/settings/ChangePasswordModal.svelte b/packages/builder/src/components/settings/ChangePasswordModal.svelte index d78c4c7efd..358e238092 100644 --- a/packages/builder/src/components/settings/ChangePasswordModal.svelte +++ b/packages/builder/src/components/settings/ChangePasswordModal.svelte @@ -8,7 +8,7 @@ const updatePassword = async () => { try { - await auth.updateSelf({ ...$auth.user, password }) + await auth.updateSelf({ password }) notifications.success("Password changed successfully") } catch (error) { notifications.error("Failed to update password") diff --git a/packages/builder/src/components/settings/UpdateUserInfoModal.svelte b/packages/builder/src/components/settings/UpdateUserInfoModal.svelte index 61446f0c00..96e2aa3743 100644 --- a/packages/builder/src/components/settings/UpdateUserInfoModal.svelte +++ b/packages/builder/src/components/settings/UpdateUserInfoModal.svelte @@ -10,7 +10,7 @@ const updateInfo = async () => { try { - await auth.updateSelf({ ...$auth.user, ...$values }) + await auth.updateSelf($values) notifications.success("Information updated successfully") } catch (error) { notifications.error("Failed to update information") diff --git a/packages/builder/src/pages/builder/admin/index.svelte b/packages/builder/src/pages/builder/admin/index.svelte index 77a1b43c57..6baf927973 100644 --- a/packages/builder/src/pages/builder/admin/index.svelte +++ b/packages/builder/src/pages/builder/admin/index.svelte @@ -10,8 +10,10 @@ import { goto } from "@roxi/routify" import api from "builderStore/api" import { admin, organisation } from "stores/portal" + import PasswordRepeatInput from "components/common/users/PasswordRepeatInput.svelte" let adminUser = {} + let error async function save() { try { @@ -42,13 +44,11 @@ - + - + diff --git a/packages/builder/src/pages/builder/apps/index.svelte b/packages/builder/src/pages/builder/apps/index.svelte index ef7c54a8da..7311c112b8 100644 --- a/packages/builder/src/pages/builder/apps/index.svelte +++ b/packages/builder/src/pages/builder/apps/index.svelte @@ -51,7 +51,7 @@
- +
userInfoModal.show()}> diff --git a/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte b/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte index b68ad85752..3eaf048872 100644 --- a/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte +++ b/packages/builder/src/pages/builder/auth/_components/GoogleButton.svelte @@ -1,24 +1,26 @@ - - -
- google icon -

Sign in with Google

-
-
-
+{#if show} + + +
+ google icon +

Sign in with Google

+
+
+
+{/if} diff --git a/packages/builder/src/pages/builder/portal/manage/users/index.svelte b/packages/builder/src/pages/builder/portal/manage/users/index.svelte index 0c136574d7..284591c4e6 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/index.svelte @@ -53,9 +53,8 @@ Users - Users are the common denominator in Budibase. Each user is assigned to a - group that contains apps and permissions. In this section, you can add - users, or edit and delete an existing user. + Each user is assigned to a group that contains apps and permissions. In + this section, you can add users, or edit and delete an existing user. diff --git a/packages/builder/src/stores/portal/auth.js b/packages/builder/src/stores/portal/auth.js index c642a5708d..517aad9fc4 100644 --- a/packages/builder/src/stores/portal/auth.js +++ b/packages/builder/src/stores/portal/auth.js @@ -1,25 +1,42 @@ -import { writable } from "svelte/store" +import { derived, writable, get } from "svelte/store" import api from "../../builderStore/api" export function createAuthStore() { - const store = writable({ user: null }) + const user = writable(null) + const store = derived(user, $user => { + let initials = null + if ($user) { + if ($user.firstName) { + initials = $user.firstName[0] + if ($user.lastName) { + initials += $user.lastName[0] + } + } else { + initials = $user.email[0] + } + } + return { + user: $user, + initials, + } + }) return { subscribe: store.subscribe, checkAuth: async () => { const response = await api.get("/api/admin/users/self") if (response.status !== 200) { - store.update(state => ({ ...state, user: null })) + user.set(null) } else { - const user = await response.json() - store.update(state => ({ ...state, user })) + const json = await response.json() + user.set(json) } }, login: async creds => { const response = await api.post(`/api/admin/auth`, creds) const json = await response.json() if (response.status === 200) { - store.update(state => ({ ...state, user: json.user })) + user.set(json.user) } else { throw "Invalid credentials" } @@ -31,12 +48,13 @@ export function createAuthStore() { throw "Unable to create logout" } await response.json() - store.update(state => ({ ...state, user: null })) + user.set(null) }, - updateSelf: async user => { - const response = await api.post("/api/admin/users/self", user) + updateSelf: async fields => { + const newUser = { ...get(user), ...fields } + const response = await api.post("/api/admin/users/self", newUser) if (response.status === 200) { - store.update(state => ({ ...state, user: { ...state.user, ...user } })) + user.set(newUser) } else { throw "Unable to update user details" } diff --git a/packages/worker/src/api/controllers/admin/configs.js b/packages/worker/src/api/controllers/admin/configs.js index 7845eee0d6..8a6788cdfd 100644 --- a/packages/worker/src/api/controllers/admin/configs.js +++ b/packages/worker/src/api/controllers/admin/configs.js @@ -168,6 +168,11 @@ exports.configChecklist = async function (ctx) { type: Configs.SMTP, }) + // They have set up Google Auth + const oauthConfig = await getScopedFullConfig(db, { + type: Configs.GOOGLE, + }) + // They have set up an admin user const users = await db.allDocs( getGlobalUserParams(null, { @@ -180,6 +185,7 @@ exports.configChecklist = async function (ctx) { apps: appDbNames.length, smtp: !!smtpConfig, adminUser, + oauth: !!oauthConfig, } } catch (err) { ctx.throw(err.status, err)