Skip to content

Commit

Permalink
fix bug not to trim space of login username (#1806)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored and appleboy committed May 29, 2017
1 parent 4fd55d8 commit bbe6aa3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion models/login_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bbe6aa3

Please sign in to comment.