Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ public ResponseEntity<?> authenticate(@RequestBody NewUserRequest request) {
//clear context to be safe
SecurityContextHolder.clearContext();

if (request.getPassword().trim().length() < 8)//checks to make sure password is at least 8 characters long
{
log.error("Too Short Password");
Map<String, String> error = ImmutableMap.
of("error", "The password is too short",
"message", "The password must be at least 8 characters long.");
return new ResponseEntity<>(error, HttpStatus.UNAUTHORIZED);
}

Authentication auth = new UsernamePasswordAuthenticationToken(request.getUsername(), request.getPassword());
try {
auth = beerBuddyAuthenticationManager.authenticate(auth);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public class UserController implements BeerMapper {
@RequestMapping(method=RequestMethod.POST)
public ResponseEntity<?> create(@RequestBody NewUserRequest request) {
try {
if (request.getPassword().trim().length() < 8)//checks to make sure password is at least 8 characters long
{
Map<String, String> error = ImmutableMap.
of("error", "The password is too short",
"message", "The password must be at least 8 characters long.");
return new ResponseEntity<>(error, HttpStatus.UNAUTHORIZED);
}

User user = userService.createUser(request.getUsername(), request.getPassword());
UserProfile profile = new UserProfile();
profile.setEmail(request.getEmail());
Expand Down