mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-16 21:39:11 +00:00
docs: clarify confusing user update logic
This commit is contained in:
@@ -296,15 +296,21 @@ func (s *UserService) updateUserInternal(ctx context.Context, userID string, upd
|
|||||||
isLdapUser := user.LdapID != nil && s.appConfigService.GetDbConfig().LdapEnabled.IsTrue()
|
isLdapUser := user.LdapID != nil && s.appConfigService.GetDbConfig().LdapEnabled.IsTrue()
|
||||||
allowOwnAccountEdit := s.appConfigService.GetDbConfig().AllowOwnAccountEdit.IsTrue()
|
allowOwnAccountEdit := s.appConfigService.GetDbConfig().AllowOwnAccountEdit.IsTrue()
|
||||||
|
|
||||||
// For LDAP users or if own account editing is not allowed, only allow updating the locale unless it's an LDAP sync
|
|
||||||
if !isLdapSync && (isLdapUser || (!allowOwnAccountEdit && updateOwnUser)) {
|
if !isLdapSync && (isLdapUser || (!allowOwnAccountEdit && updateOwnUser)) {
|
||||||
|
// Restricted update: Only locale can be changed when:
|
||||||
|
// - User is from LDAP, OR
|
||||||
|
// - User is editing their own account but global setting disallows self-editing
|
||||||
|
// (Exception: LDAP sync operations can update everything)
|
||||||
user.Locale = updatedUser.Locale
|
user.Locale = updatedUser.Locale
|
||||||
} else {
|
} else {
|
||||||
|
// Full update: Allow updating all personal fields
|
||||||
user.FirstName = updatedUser.FirstName
|
user.FirstName = updatedUser.FirstName
|
||||||
user.LastName = updatedUser.LastName
|
user.LastName = updatedUser.LastName
|
||||||
user.Email = updatedUser.Email
|
user.Email = updatedUser.Email
|
||||||
user.Username = updatedUser.Username
|
user.Username = updatedUser.Username
|
||||||
user.Locale = updatedUser.Locale
|
user.Locale = updatedUser.Locale
|
||||||
|
|
||||||
|
// Admin-only fields: Only allow updates when not updating own account
|
||||||
if !updateOwnUser {
|
if !updateOwnUser {
|
||||||
user.IsAdmin = updatedUser.IsAdmin
|
user.IsAdmin = updatedUser.IsAdmin
|
||||||
user.Disabled = updatedUser.Disabled
|
user.Disabled = updatedUser.Disabled
|
||||||
|
|||||||
Reference in New Issue
Block a user