From b02d5bb85d8ca3057bd3c8c18dc147244b6d4713 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 26 Nov 2017 10:14:01 +0800 Subject: [PATCH 1/2] fix error when add user has full name to team --- routers/org/teams.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routers/org/teams.go b/routers/org/teams.go index 1ac4bff2e865f..4eef80836ced5 100644 --- a/routers/org/teams.go +++ b/routers/org/teams.go @@ -6,6 +6,7 @@ package org import ( "path" + "strings" "github.com/Unknwon/com" @@ -76,6 +77,9 @@ func TeamsAction(ctx *context.Context) { return } uname := ctx.Query("uname") + if strings.Contains(uname, "(") && strings.HasSuffix(uname, ")") { + uname = strings.TrimSpace(strings.Split(uname, "(")[0]) + } var u *models.User u, err = models.GetUserByName(uname) if err != nil { From e0eb57d95e37decc5d67cc6b7905b1accdbd88f5 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 26 Nov 2017 13:59:17 +0800 Subject: [PATCH 2/2] add comment for extra uname check --- routers/org/teams.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/org/teams.go b/routers/org/teams.go index 4eef80836ced5..e9abfe791767d 100644 --- a/routers/org/teams.go +++ b/routers/org/teams.go @@ -77,6 +77,7 @@ func TeamsAction(ctx *context.Context) { 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]) }