RE: [coldbox:17925] [ColdBox 3.5.0] How use security interceptor to redirect to page

What I do is fairly straight forward:

  1. In preProcess() if a user is trying to access a page they can’t, set the current event and request collection in a session var.
  2. Then redirect them to the login screen.
  3. After login process, check and see if there’s a referring URL in session and if so, build a URL string out of the event and rc and redirect them there
  4. If there’s nothing in session (meaning they came directly to the login screen), just take them to the default logged in home page.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

I use solitary module for my secure area.

I have created a new interceptors to manage redirection.

interceptors = [
//redirect
{class="#moduleMapping#.interceptors.redirect"},
//security
{class=“coldbox.system.interceptors.security”,
properties={
rulesSource=“xml”,
rulesFile="#modulePath#/config/securityRules.xml.cfm",
preEventSecurity=“true”,
validatorModel=“securityService@Solitary”
}
}
];

In my redirect interceptor I have this:

function configure(){}

function preProcess(event,rc){

var rc = Event.getCollection();
var oSession = getPlugin(“SessionStorage”);
oSession.setVar(“redirect”,event.getEventName());

}

but not seems to work…

When you detect a user is not logged in via solitary save the current event in the session scope. Then in your login after succesfully validating the user look for the session variable. If it exists then redirect.

Daniel M