Skip to content

Commit bbe6aa3

Browse files
lunnyappleboy
authored andcommitted
fix bug not to trim space of login username (#1806)
1 parent 4fd55d8 commit bbe6aa3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

models/login_source.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,12 @@ func UserSignIn(username, password string) (*User, error) {
635635
}
636636
}
637637
} else {
638-
user = &User{LowerName: strings.ToLower(strings.TrimSpace(username))}
638+
trimmedUsername := strings.TrimSpace(username)
639+
if len(trimmedUsername) == 0 {
640+
return nil, ErrUserNotExist{0, username, 0}
641+
}
642+
643+
user = &User{LowerName: strings.ToLower(trimmedUsername)}
639644
}
640645

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

0 commit comments

Comments
 (0)