Redirecting a User after Login / Logon

This situation can be common in places like Universities. Students need to be redirected after login to some 'special' page, or an employee needs to be redirected if it is their first login, etcetera.

You could be forgiven for thinking this might be easily configurable somewhere. It doesn't seem to be (leave me a message if it is). Here's how I've done it.

I've modified:

Note You're going to need a Global Variable to hold whether the user has been redirected yet or not, we only want to redirect once. You could easily put them into an endless redirect loop.

Global boolean &blnStudentHasBeenRedirected;

(You have to place that just after end-class;)

There is a Method getHomepageJS that, as its name implies, get JavaScript for the home page.
Return GetHTMLText(HTML.PT_HP2_JS_INCLUDE, &cookieJS, &refreshJS, &refreshPgltJS, &saveWarnCrossDomainJS, &saveWarnJS, &hpDndJS | Char(10) | Char(13) | %This.getCSSOverride());

Note the getCSSOverride method. This is where I've added my extra JavaScript, the 6th bind variable.

method getCSSOverride
   /+ Returns String +/
   /* derived classes can override this method to add their own css override */
   Local string &override = "";
   If %Request.BrowserType = "IE" Then
      &override = "<!--[if lt IE 9]>" | Char(10) | Char(13) | "<script type=""text/javascript"" src=""" | %Response.GetJavaScriptURL(HTML.AMS_IE9) | """></script>" | Char(10) | Char(13) | "<![endif]-->";
   Local AMS_PT_BRANDING:AmsHeader &myAmsHeader = create AMS_PT_BRANDING:AmsHeader();
   If &myAmsHeader.isStudent Then
      &override = &override | Char(10) | Char(13) | "<link rel=""stylesheet"" href=""" | %Response.GetStyleSheetURL(StyleSheet.AMS_SSS_STYLE_REF) | """ type=""text/css"">";
      /* Begin: QC1302 */
      If &blnStudentHasBeenRedirected <> True Then
         &blnStudentHasBeenRedirected = True;
         &override = &override | Char(10) | Char(13) | "<script type=""text/javascript"">""../c/AMS_EOL.AMSW3_STDNT_HOME.GBL"");</script>";
      /* End: QC1302 */
   Return &override;

If they're a student, and they haven't already been redirected once, redirect them to the student home page.


David Vandiver said...

What HTML object do you have in your HTML.AMS_IE9?