Created
July 24, 2014 07:41
-
-
Save agonist/cf3043944c43e734d7d0 to your computer and use it in GitHub Desktop.
login route
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Route(method = HttpMethod.POST, uri = "/login") | |
public Result login(@Body User user) { | |
Subject currentUser = SecurityUtils.getSubject(); | |
UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getPassword()); | |
try { | |
currentUser.login(token); | |
} catch (UnknownAccountException uae) { | |
context().flash().error("Unknown account"); | |
return loginForm(); | |
} catch (IncorrectCredentialsException ice) { | |
context().flash().error("Wrong password"); | |
return loginForm(); | |
} catch (LockedAccountException lae) { | |
context().flash().error("Account locked"); | |
return loginForm(); | |
} catch (AuthenticationException ae) { | |
context().flash().error("some error"); | |
return loginForm(); | |
} | |
return redirect("protected"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment