Skip to content

Commit 19d889d

Browse files
lunnyappleboy
authored andcommitted
fix bug not to trim space of login username (#1796)
1 parent ff2464c commit 19d889d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

models/login_source.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,12 @@ func UserSignIn(username, password string) (*User, error) {
641641
}
642642
}
643643
} else {
644-
user = &User{LowerName: strings.ToLower(strings.TrimSpace(username))}
644+
trimmedUsername := strings.TrimSpace(username)
645+
if len(trimmedUsername) == 0 {
646+
return nil, ErrUserNotExist{0, username, 0}
647+
}
648+
649+
user = &User{LowerName: strings.ToLower(trimmedUsername)}
645650
}
646651

647652
hasUser, err := x.Get(user)

0 commit comments

Comments
 (0)