From 9872608d61a486f7b775f314d9392e0620bcd891 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Thu, 3 Jul 2025 10:57:56 +0200 Subject: [PATCH] fix: allow profile picture update even if "allow own account edit" enabled --- .../form/profile-picture-settings.svelte | 24 ++++++++--- .../src/routes/settings/account/+page.svelte | 42 +++++++++---------- .../settings/account/account-form.svelte | 42 ++++++++++--------- 3 files changed, 63 insertions(+), 45 deletions(-) diff --git a/frontend/src/lib/components/form/profile-picture-settings.svelte b/frontend/src/lib/components/form/profile-picture-settings.svelte index 5160582d..a2ab355c 100644 --- a/frontend/src/lib/components/form/profile-picture-settings.svelte +++ b/frontend/src/lib/components/form/profile-picture-settings.svelte @@ -3,6 +3,7 @@ import * as Avatar from '$lib/components/ui/avatar'; import Button from '$lib/components/ui/button/button.svelte'; import { m } from '$lib/paraglide/messages'; + import appConfigStore from '$lib/stores/application-configuration-store'; import { cachedProfilePicture } from '$lib/utils/cached-image-util'; import { LucideLoader, LucideRefreshCw, LucideUpload } from '@lucide/svelte'; import { onMount } from 'svelte'; @@ -54,8 +55,16 @@ label: m.reset(), action: async () => { isLoading = true; - await resetCallback().catch(); - isLoading = false; + try { + await resetCallback(); + await fetch(cachedProfilePicture.getUrl(userId, { skipCache: true })) + .then((response) => response.blob()) + .then((blob) => { + imageDataURL = URL.createObjectURL(blob); + }); + } finally { + isLoading = false; + } } } }); @@ -64,7 +73,7 @@
- {#if isLdapUser} + {#if isLdapUser && $appConfigStore.ldapEnabled} @@ -96,7 +105,7 @@

{m.profile_picture()}

- {#if isLdapUser} + {#if isLdapUser && $appConfigStore.ldapEnabled}

{m.profile_picture_is_managed_by_ldap_server()}

@@ -105,7 +114,12 @@ {m.click_profile_picture_to_upload_custom()}

{m.image_should_be_in_format()}

- diff --git a/frontend/src/routes/settings/account/+page.svelte b/frontend/src/routes/settings/account/+page.svelte index 9aa544dc..7db9749d 100644 --- a/frontend/src/routes/settings/account/+page.svelte +++ b/frontend/src/routes/settings/account/+page.svelte @@ -34,6 +34,10 @@ const userService = new UserService(); const webauthnService = new WebAuthnService(); + const userInfoInputDisabled = $derived( + !$appConfigStore.allowOwnAccountEdit || (!!account.ldapId && $appConfigStore.ldapEnabled) + ); + async function updateAccount(user: UserCreate) { let success = true; await userService @@ -118,27 +122,23 @@
-
- - - - - {m.account_details()} - - - - - - -
+ + + + + {m.account_details()} + + + + + +
diff --git a/frontend/src/routes/settings/account/account-form.svelte b/frontend/src/routes/settings/account/account-form.svelte index 13441b2b..f89bdde7 100644 --- a/frontend/src/routes/settings/account/account-form.svelte +++ b/frontend/src/routes/settings/account/account-form.svelte @@ -15,12 +15,14 @@ callback, account, userId, - isLdapUser = false + isLdapUser = false, + userInfoInputDisabled = false }: { account: UserCreate; userId: string; callback: (user: UserCreate) => Promise; isLdapUser?: boolean; + userInfoInputDisabled?: boolean; } = $props(); let isLoading = $state(false); @@ -78,26 +80,28 @@
-
-
-
- +
+
+
+
+ +
+
+ +
-
- +
+
+ +
+
+ +
-
-
- -
-
- -
-
-
-
- -
+
+ +
+