Browse Source

Fix error when add user has full name to team (#2973)

* fix error when add user has full name to team

* add comment for extra uname check
Lunny Xiao 1 year ago
parent
commit
061c501d54
1 changed files with 5 additions and 0 deletions
  1. 5 0
      routers/org/teams.go

+ 5 - 0
routers/org/teams.go

@@ -6,6 +6,7 @@ package org
6 6
 
7 7
 import (
8 8
 	"path"
9
+	"strings"
9 10
 
10 11
 	"github.com/Unknwon/com"
11 12
 
@@ -76,6 +77,10 @@ func TeamsAction(ctx *context.Context) {
76 77
 			return
77 78
 		}
78 79
 		uname := ctx.Query("uname")
80
+		// uname may be formatted as "username (fullname)"
81
+		if strings.Contains(uname, "(") && strings.HasSuffix(uname, ")") {
82
+			uname = strings.TrimSpace(strings.Split(uname, "(")[0])
83
+		}
79 84
 		var u *models.User
80 85
 		u, err = models.GetUserByName(uname)
81 86
 		if err != nil {