Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP 500 retuend when change my username #25621

Closed
asforest opened this issue Jul 1, 2023 · 0 comments · Fixed by #25637
Closed

HTTP 500 retuend when change my username #25621

asforest opened this issue Jul 1, 2023 · 0 comments · Fixed by #25637
Labels

Comments

@asforest
Copy link

asforest commented Jul 1, 2023

Description

When I change my username of Gitea in the profile page, the server returned HTTP 500 Internal Server Error.

This are the related logs:

2023/07/01 22:53:21 ...r/setting/profile.go:114:ProfilePost() [D] [64a03de1] Changing name for unity-package-manager to unity-package-bot2
2023/07/01 22:53:21 ...r/setting/profile.go:75:HandleUsernameChange() [E] [64a03de1] ChangeUserName: UNIQUE constraint failed: user_redirect.lower_name
2023/07/01 22:53:21 ...s/context/context.go:222:HTML() [D] [64a03de1] Template: status/500
2023/07/01 22:53:23 ...s/context/context.go:222:HTML() [D] [64a03de3] Template: user/settings/profile
2023/07/01 22:53:30 ...r/setting/profile.go:114:ProfilePost() [D] [64a03dea] Changing name for unity-package-manager to unity-package-bot
2023/07/01 22:53:30 ...r/setting/profile.go:75:HandleUsernameChange() [E] [64a03dea] ChangeUserName: UNIQUE constraint failed: user_redirect.lower_name
2023/07/01 22:53:30 ...s/context/context.go:222:HTML() [D] [64a03dea] Template: status/500

And this is a git diff file given by @lunny to fix.

diff --git a/models/user/redirect.go b/models/user/redirect.go
index 9d8903c05..42e991888 100644
--- a/models/user/redirect.go
+++ b/models/user/redirect.go
@@ -64,6 +64,10 @@ func NewUserRedirect(ctx context.Context, ID int64, oldUserName, newUserName str
        oldUserName = strings.ToLower(oldUserName)
        newUserName = strings.ToLower(newUserName)

+       if err := DeleteUserRedirect(ctx, oldUserName); err != nil {
+               return err
+       }
+
        if err := DeleteUserRedirect(ctx, newUserName); err != nil {
                return err
        }

Gitea Version

1.19.3

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

aa

Git Version

No response

Operating System

Debian 11

How are you running Gitea?

In Docker

Database

SQLite

silverwind pushed a commit that referenced this issue Jul 3, 2023
Fix #25621

Co-authored-by: Giteabot <teabot@gitea.io>
GiteaBot added a commit to GiteaBot/gitea that referenced this issue Jul 3, 2023
Fix go-gitea#25621

Co-authored-by: Giteabot <teabot@gitea.io>
GiteaBot added a commit to GiteaBot/gitea that referenced this issue Jul 3, 2023
Fix go-gitea#25621

Co-authored-by: Giteabot <teabot@gitea.io>
lafriks pushed a commit that referenced this issue Jul 3, 2023
Backport #25637 by @lunny

Fix #25621

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
silverwind pushed a commit that referenced this issue Jul 3, 2023
Backport #25637 by @lunny

Fix #25621

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Codeberg-org pushed a commit to Codeberg-org/gitea that referenced this issue Jul 5, 2023
Backport go-gitea#25637 by @lunny

Fix go-gitea#25621

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
(cherry picked from commit 37bf5e7)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant