]> source.dussan.org Git - gitea.git/commitdiff
Fix error when add user has full name to team (#2973) (#2975)
authorLunny Xiao <xiaolunwen@gmail.com>
Sun, 26 Nov 2017 17:53:07 +0000 (01:53 +0800)
committerLauris BH <lauris@nix.lv>
Sun, 26 Nov 2017 17:53:07 +0000 (19:53 +0200)
* fix error when add user has full name to team

* add comment for extra uname check

routers/org/teams.go

index 1ac4bff2e865fa3402051818b26e44390f1dee99..e9abfe791767dc1104a2210e6c470577dcb4ef74 100644 (file)
@@ -6,6 +6,7 @@ package org
 
 import (
        "path"
+       "strings"
 
        "github.com/Unknwon/com"
 
@@ -76,6 +77,10 @@ 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])
+               }
                var u *models.User
                u, err = models.GetUserByName(uname)
                if err != nil {