0
votes

i have a site.and i am using apache shiro in this site.i have a problem.the input is done from the login page.but if you logged in,I want to restrict access to this page.page should tell " hey come on man! You have already logged in" then guide to another page(for.ex: home.jsf).How can I make this forwarding with shiro web filters? shiro.ini

[urls]
/login.xhtml = anon
1

1 Answers

0
votes

Read the tutorial here:

http://shiro.apache.org/webapp-tutorial.html

Change your ini to:

[main]
shiro.loginUrl = /login.xhtml

[urls]
/login.xhtml = authc

I you want to redirect when the user is already logged in you can do this using the following Java code in a servlet or filter:

if (SecurityUtils.getSubject().isAuthenticated()){
    response.sendRedirect(request.getContextPath() + "/home.jsf");
}

For more details check out this post: How to redirect already authenticated user from login page to home page