Reputation: 2183
I run a code for login like:
public String login(String username,String password){
Authentication request = new UsernamePasswordAuthenticationToken(username,password);
Authentication result = authenticationManager.authenticate(request);
SecurityContextHolder.getContext().setAuthentication(result);
return null;
}
I do not use jsf and do not know how to redirect the page to requested secured page after successful login.
I was getting facesContext when using it but now i am not using.
How can redirect by code?
Upvotes: 0
Views: 308
Reputation: 8574
Just return the view after checking for isAuthenticated(), like this:
if (authenticationResponseToken.isAuthenticated()) {
//lookup authentication success url, or find redirect parameter from login bean
return "/secure/examples";
}
See also:
Upvotes: 1