fix bug not to trim space of login username (#1796)

This commit is contained in:
Lunny Xiao 2017-05-25 00:12:00 +08:00 committed by Bo-Yi Wu
parent ff2464c87d
commit 19d889daa2

View File

@ -641,7 +641,12 @@ func UserSignIn(username, password string) (*User, error) {
} }
} }
} else { } else {
user = &User{LowerName: strings.ToLower(strings.TrimSpace(username))} trimmedUsername := strings.TrimSpace(username)
if len(trimmedUsername) == 0 {
return nil, ErrUserNotExist{0, username, 0}
}
user = &User{LowerName: strings.ToLower(trimmedUsername)}
} }
hasUser, err := x.Get(user) hasUser, err := x.Get(user)