fix: use consistent GetUser family functions (#37553) (#37589)

Backport #37553

fixes adding collaborative owners in Actions settings when the user or
organization name contains capital letters.

Fixes #37548

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Nicolas <bircni@icloud.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot
2026-05-07 08:43:45 -07:00
committed by GitHub
parent 2bafa41554
commit 7d77631881
4 changed files with 30 additions and 57 deletions
+4 -8
View File
@@ -6,7 +6,6 @@ package setting
import (
"errors"
"net/http"
"strings"
"code.gitea.io/gitea/models/actions"
repo_model "code.gitea.io/gitea/models/repo"
@@ -94,15 +93,12 @@ func ActionsUnitPost(ctx *context.Context) {
}
func AddCollaborativeOwner(ctx *context.Context) {
name := strings.ToLower(ctx.FormString("collaborative_owner"))
ownerID, err := user_model.GetUserOrOrgIDByName(ctx, name)
collUser, err := user_model.GetUserByName(ctx, ctx.FormString("collaborative_owner"))
if err != nil {
if errors.Is(err, util.ErrNotExist) {
ctx.Flash.Error(ctx.Tr("form.user_not_exist"))
ctx.JSONErrorNotFound()
ctx.JSONError(ctx.Tr("form.user_not_exist"))
} else {
ctx.ServerError("GetUserOrOrgIDByName", err)
ctx.ServerError("GetUserByName", err)
}
return
}
@@ -113,7 +109,7 @@ func AddCollaborativeOwner(ctx *context.Context) {
return
}
actionsCfg := actionsUnit.ActionsConfig()
actionsCfg.AddCollaborativeOwner(ownerID)
actionsCfg.AddCollaborativeOwner(collUser.ID)
if err := repo_model.UpdateRepoUnitConfig(ctx, actionsUnit); err != nil {
ctx.ServerError("UpdateRepoUnitConfig", err)
return