diff options
author | Lunny Xiao | 2017-05-29 19:10:11 +0800 |
---|---|---|
committer | Bo-Yi Wu | 2017-05-29 06:10:11 -0500 |
commit | bbe6aa349ff0c87e5fefe3dfbc6e16c7c1cb2795 (patch) | |
tree | 701c18d0b21e64e3491d6bad30a84faa33ccd564 | |
parent | 4fd55d87965823b5acc79be43ac7832dc2fab563 (diff) |
fix bug not to trim space of login username (#1806)v1.1.2
-rw-r--r-- | models/login_source.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/models/login_source.go b/models/login_source.go index 401bbf671..b31425318 100644 --- a/models/login_source.go +++ b/models/login_source.go @@ -635,7 +635,12 @@ func UserSignIn(username, password string) (*User, error) { } } } 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) |