1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-13 04:58:19 +00:00

Allow adding collaborators with (fullname) (#3103) (#3168)

* Allow adding collaborators with (fullname)

Signed-off-by: Sasha Varlamov <sasha@sashavarlamov.com>

* Refactor username suffix to utils pkg

Signed-off-by: Sasha Varlamov <sasha@sashavarlamov.com>
This commit is contained in:
Lauris BH
2017-12-12 09:23:08 +02:00
committed by Bo-Yi Wu
parent d63ca66623
commit e893aced89
4 changed files with 38 additions and 6 deletions

View File

@@ -15,6 +15,7 @@ import (
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/routers/utils"
)
const (
@@ -76,11 +77,7 @@ func TeamsAction(ctx *context.Context) {
ctx.Error(404)
return
}
uname := ctx.Query("uname")
// uname may be formatted as "username (fullname)"
if strings.Contains(uname, "(") && strings.HasSuffix(uname, ")") {
uname = strings.TrimSpace(strings.Split(uname, "(")[0])
}
uname := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Query("uname")))
var u *models.User
u, err = models.GetUserByName(uname)
if err != nil {