Add length check for username.

This commit is contained in:
Kavin 2022-06-26 03:01:19 +01:00
parent c558572953
commit f5e881e0e4
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD

View file

@ -633,6 +633,12 @@ public class ResponseHelper {
if (StringUtils.isBlank(user) || StringUtils.isBlank(pass)) if (StringUtils.isBlank(user) || StringUtils.isBlank(pass))
return mapper.writeValueAsBytes(new InvalidRequestResponse()); return mapper.writeValueAsBytes(new InvalidRequestResponse());
if (user.length() > 24)
return mapper.writeValueAsBytes(
mapper.createObjectNode()
.put("error", "The username must be less than 24 characters")
);
user = user.toLowerCase(); user = user.toLowerCase();
try (Session s = DatabaseSessionFactory.createSession()) { try (Session s = DatabaseSessionFactory.createSession()) {