Skip to content

Commit

Permalink
fix bug not to trim space of login username (#1796)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored and appleboy committed May 24, 2017
1 parent ff2464c commit 19d889d
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 @@ -641,7 +641,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 19d889d

Please sign in to comment.