Skip to content

Commit

Permalink
#849 | Add null check for invalid username
Browse files Browse the repository at this point in the history
  • Loading branch information
himeshr committed Jan 16, 2025
1 parent 0c1b543 commit 0a78ce4
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public UserLoginApiController(AuthService authService, UserRepository userReposi
@RequestMapping(value = "/api/user/generateToken", method = RequestMethod.POST)
public ResponseEntity<GenerateTokenResult> generateTokenForUser(@RequestBody GenerateTokenRequest request) throws EntityNotFoundException {
User user = userRepository.findByUsername(request.getUsername());
if (user == null) {
throw new EntityNotFoundException("User not found with username: " + request.getUsername());
}
if (!user.getUserSettings().isAllowedToInvokeTokenGenerationAPI()) {
throw AvniAccessException.createForUserNotAllowedTokenGeneration(user);
}
Expand Down

0 comments on commit 0a78ce4

Please sign in to comment.