From 37bf5e761ace3df980566c0be2146e21f24b9fe3 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Mon, 3 Jul 2023 17:00:44 -0400 Subject: [PATCH] Fix bug when change user name (#25637) (#25645) Backport #25637 by @lunny Fix #25621 Co-authored-by: Lunny Xiao --- models/user/redirect.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/models/user/redirect.go b/models/user/redirect.go index 9d8903c059..42e991888a 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 }