0

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
user3565914
  • 51
  • 1
  • 9

1 Answers1

0

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

Community
  • 1
  • 1
Wouter
  • 3,976
  • 2
  • 31
  • 50
  • thanks for reply.but I'm having the same problem again.assuming that you logged in (localhost:8080/login.jsf) and redirected to home.jsf. and again you manuel open the same url (localhost:8080/login.jsf) when logged in. You're faced with the same screen.and you say "but i logged in? what happend?I still did not logout.Do you want me to login again?" and if you log in again and nothing happens on the same screen because your session didnot close.If you logged on, I want to never open the page until you log off. how can i do?I apologize for my bad english. – user3565914 May 01 '14 at 13:05
  • added extra info to the answer – Wouter May 01 '14 at 13:10
  • http://stackoverflow.com/questions/8399045/conditional-redirection-in-jsf/8399591#8399591 its very quick solution thanks a lot – user3565914 May 01 '14 at 16:03