Re: Simple login rewrite

Splash Forums Rewrite Users Simple login rewrite Re: Simple login rewrite

#22924

RedShadow
Participant

I am using 1.1.0.Final

The thing with the 404 error is gone now. I tried 2 different approaches now, first with addRule(Join) and second with defineRule() but as I have seen in my JSF views, only the addRule(Join) things are rewritten when using <h:link>

Is that supposed? What’s the difference between those approaches?

Also in the following config, the outcome /admin/passwordForgotten.xhtml will be rewritten to /admin/forgot-pw but /admin/login.xhtml will not be rewritten to /admin. Why is that?

public class SystemConfigurationProvider extends HttpConfigurationProvider {

private static final Logger LOG = LoggerFactory

.getLogger(SystemConfigurationProvider.class);

@Inject

private UserSessionBean userSessionBean;

@Override

public Configuration getConfiguration(final ServletContext context) {

final Condition loggedIn = new Condition() {

@Override

public boolean evaluate(Rewrite event, EvaluationContext context) {

return userSessionBean.hasBackendAccess();

}

};

return ConfigurationBuilder

.begin()

/*

* Forgot Password page

*/

.addRule(Join.path("/admin/forgot-pw")

.to("/admin/passwordForgotten.xhtml")

.when(Not.any(loggedIn)))

/*

* Redirect to login page if not logged in

*/

.addRule(

Join.path("/admin{0}")

.to("/admin/login.xhtml")

.where("0")

.matches(".*")

.when(Not

.any(Path.matches("/admin/login.xhtml"))

.andNot(Path

.matches("/admin/passwordForgotten.xhtml"))

.andNot(loggedIn)))

/*

* Redirect to admin page if logged in

*/

.addRule(

Join.path("/admin{0}")

.to("/admin/admin.xhtml")

.where("0")

.matches(".*")

.when(loggedIn))

// /*

// * Redirect to login page if not logged in

// */

// .defineRule()

// .when(Path.matches("/admin{0}").where("0").matches(".*")

// .andNot(Path.matches("/admin/login.xhtml"))

// .andNot(Path.matches("/admin/passwordForgotten.xhtml"))

// .andNot(loggedIn))

// .perform(Forward.to("/admin/login.xhtml").and(new Operation() {

//

// @Override

// public void perform(Rewrite event, EvaluationContext context) {

// LOG.error("To Login");

// }

// }))

// /*

// * Redirect to admin page if logged in

// */

// .defineRule()

// .when(Path.matches("/admin{0}").where("0").matches(".*")

// .and(loggedIn))

// .perform(Forward.to("/admin/admin.xhtml").and(new Operation() {

//

// @Override

// public void perform(Rewrite event, EvaluationContext context) {

// LOG.error("To CMS");

// }

// }))

;

}

@Override

public int priority() {

return 10;

}

}