0

This is my first attempt at subsystems and for the most part things are going well. I’m having trouble redirecting usesr from a subsystem site to the main top site when the session ends.

Here may site structure, it pretty standard.

  1. I’ve logged in from the mainSite
  2. Base on my login I get redirected to the appropriate subsystem i.e. (subSite1, subSite2)
  3. When my session ends I want to be redirect to mainSite.login, instead it’s redirecting me to subSite1.login.

My question is, how do I redirect user from the subsystem sites to the mainSite login?

Here is my site structure.

mainSite
-assets
-contorllers
    -login.cfc
    -security.cfc
-framework
-layouts
-model
-subsystems
    -subSite1
        -controllers
        -layouts
        -model
        -views
            -main
                -default.cfm
        application.cfc
        index.cfm
    -subSite2
        ...
-views
    -login
        -default.cfm (login form)
application.cfc
index.cfm

The /mainSite/controllers/security.cfm is straight from the FW/1 download with minor changes for my needs. I've tried updating the redirect in authorize() function but have not had luck. Thank you in advance for your insights.

component {

function init( fw ) {
  variables.fw = fw;
}

function session( rc ) {
  // set up the user's session
  session.auth = {};
  session.auth.isLoggedIn = false;
  session.auth.fullname = 'Guest';
}

function authorize( rc ) {
  // check to make sure the user is logged on
  if (not(structKeyExists(session, "auth") && session.auth.isLoggedIn ) && !listfindnocase('login', variables.fw.getSection() ) && !listfindnocase('main.error', variables.fw.getFullyQualifiedAction() )) {
  variables.fw.redirect('login');
  }
}

}
user752746
  • 617
  • 9
  • 31

2 Answers2

1

You need to provide what essentially amounts to a fully-qualified redirect. If your default ("top level") subsystem is called "main" and the default section is called "main" then that would be like this:

variables.fw.redirect('main:main.login');
Adam Tuttle
  • 19,505
  • 17
  • 80
  • 113
  • Hi Adam, thanks for your quick response. Unfortunately this did work, I got this error. "This page can’t be displayed". Sorry, if I wasn't clear in my question. I've added my site structure so i can better explain. I would like to redirect users from subSite1 (/mainSite/subsystems/subSite1/main) to mainSite (/mainSite/login) login page when the is expired. – user752746 Apr 29 '16 at 16:48
  • It seems to me you don't understand how subsystems work. You should start by reading the documentation: http://framework-one.github.io/documentation/using-subsystems.html – Adam Tuttle Apr 29 '16 at 17:59
  • You're right this is my first subsystem application and I'm trying to wrap my head around FW/1 subsystem. Given my site structure above, are all site required (should) be inside the subsystems folder? Thank you for your insights! – user752746 Apr 29 '16 at 18:30
-1

I was able to get the desired outcome by using location().

//variables.fw.redirect('login');
location(url="/mainSite/login");

I want to update this answer in case others run into the same scenario. Sean Corfield provided the answer on FW/1 Google group. Here's the link https://groups.google.com/forum/#!topic/framework-one/0g7TWQLg3Hs

variables.fw.redirect(':login');
user752746
  • 617
  • 9
  • 31
  • This may "work" but is not really germane to the tools you're using -- unless this "topsite" is NOT itself part of the same FW/1 application. It probably should be. It should probably be the main/default subsystem. But, if it is not, then, and only then, is your solution here the correct one. – Adam Tuttle Apr 29 '16 at 18:01
  • The "topsite" is part of the same FW/1 application. – user752746 Apr 29 '16 at 18:27
  • For what it's worth, if that's a valid path, you could redirect to it in FW/1 by doing: `variables.fw.redirectCustomURL("/mainSite/login");` See here: [FW/1 Docs redirectCustomURL()](http://framework-one.github.io/documentation/reference-manual.html#public-void-function-redirectcustomurl-string-uri-string-preserve--none-string-statuscode--302-string-header---) – Tony Junkes Apr 29 '16 at 22:37
  • Thanks Tony! I'll keep this one in mind, it may come in handy. – user752746 May 03 '16 at 16:49