This content has been marked as final.
Show 2 replies
-
1. Re: rules in login.page.xml
sjmenden Aug 26, 2008 4:26 PM (in response to 1womps1)I think you are going about this wrong, you should be adding the admin role to the identity roles when you authenticate. Then you can simply do:
<rule if="#{isUserInRole['admin']}"> <redirect view-id="/admin.xhtml"/> </rule>
-
2. Re: rules in login.page.xml
georges.goebel Aug 26, 2008 4:58 PM (in response to 1womps1)It's better to use the isUserInRole as indicated by the previous post.
But if you want to implement a custom autenticator you can do it as follows.First be sure that your autenticator is executed because I remember that when you use JASS (f.ex with ldap the authenticate-method is ignored). Check this post link to forum
Next add the corresponding code to pages.xml
<page view-id="/login.xhtml"> <navigation> <rule if="#{authenticator.admin}"> <redirect view-id="/cart.xhtml"/> </rule> <rule if="#{!authenticator.admin}"> <redirect view-id="/main2.xhtml"/> </rule> </navigation> </page>
The code for the autenticator can look like this :
private boolean admin = false; public boolean authenticate() { log.info("autenticate ...."); try { Identity.instance().authenticate(); log.info("Login to signalisation of : " + Identity.instance().getUsername()); if (Identity.instance().getUsername().equals("goebel")) { admin = true; } return true; } catch (NoResultException ex) { ex.printStackTrace(); return false; } catch (LoginException e) { e.printStackTrace(); } return false; } public boolean isAdmin() { return admin; } public void setAdmin(boolean admin) { this.admin = admin; }
That should do the trick
Georges