mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-08 14:03:24 +09:00
Backport #38480 by @Zettat123 ## How to reproduce this bug 1. Create a user with `visibility=public` 2. Update `ALLOWED_USER_VISIBILITY_MODES` setting to `limited, private` 3. Modify any field other than "User visibility" (e.g. "Full Name") 4. UI shows 500 error ## Fix Only update the visibility field when it actually changes. Co-authored-by: Zettat123 <zettat123@gmail.com>
This commit is contained in:
@@ -145,7 +145,8 @@ func UpdateUser(ctx context.Context, u *user_model.User, opts *UpdateOptions) er
|
||||
}
|
||||
}
|
||||
|
||||
if opts.Visibility.Has() {
|
||||
// only validate and persist the visibility when it actually changes
|
||||
if opts.Visibility.Has() && opts.Visibility.Value() != u.Visibility {
|
||||
if !u.IsOrganization() && !setting.Service.AllowedUserVisibilityModesSlice.IsAllowedVisibility(opts.Visibility.Value()) {
|
||||
return fmt.Errorf("visibility mode not allowed: %s", opts.Visibility.Value().String())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user