The CreatorCon Call for Content is officially open! Get started here.

Login redirecting to Service Portal

Cirrus
Kilo Sage

Hi, thought I posted this earlier so apologies if this gets duplicated.

We have just upgraded our dev instance to Madrid, but following the upgrade if an Itil user logs out and then logs back in again, they are redirected to the service portal page. I logged out as myself and then back in as admin, but even then could only get to the sp page. Adding login.do to the url makes no difference. The only way to get back in is to kill the current browser session and start again. Has anyone else experienced this or can advise what settings could be driving this.

We have no LDAP integration in DEV, and I have unchecked the system property for using LDAP for password authentication. All passwords for Dev are set by admin in the sys_user table

 

Thanks

1 ACCEPTED SOLUTION

Cirrus
Kilo Sage

Ended up raising this in HI but still dont have a solution

View solution in original post

8 REPLIES 8

Allen Andreas
Administrator
Administrator

Hello,

you'd want to check your redirect page: https://docs.servicenow.com/bundle/helsinki-servicenow-platform/page/build/service-portal/concept/c_...

and then check this link to see if you have settings here for directing to service portal: https://community.servicenow.com/community?id=community_blog&sys_id=cbcda2e9dbd0dbc01dcaf3231f961949

So both of this can affect routing. Sounds like the first link I posted would be a good start for you.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thanks Allen, very useful info.

I dont think the issue is with our set up as such. When I logged in this morning I got straight into the back end fulfiller view as expected. However, as soon as I logged out and logged back in again, I was taken to the sp view. In order to be able to log in and get back to the fulfiller view, I have to kill my current google session. Just closing the tab and opening a new one takes me back to sp.  

Vivek Verma
Giga Sage

Hi Cirrus,

 

Please Update Script Include "SpEntryPage",

 

This will solve your cache issue.

 

Please mark my response to correct answered.

 

updated script.


 


/** 
 *
 * Service Portal sample script include to indicate 
 * 1. which login page should be used
 * 2. the starting page after the user is authenticated 
 * 
 * Script is configured using system properties
 
 * PROPERTY VALUE
 * glide.entry.page.script new SPEntryPage().getLoginURL(); 
 * glide.entry.first.page.script new SPEntryPage().getFirstPageURL();
 * 
 * functions can return a path or null if no overrides are necessary
 * 
 **/
var SPEntryPage = Class.create();


SPEntryPage.prototype = {
 
 initialize: function() {
 this.logVariables = false; // for debugging 
 this.portal = "/sp/"; // The URL suffix specified in the sp_portal record
 },


/***
 *
 * Referred to by property: glide.entry.page.script
 * 
 **/
 getLoginURL: function() {
 // When requesting a page directly (eg: /problem_list.do)
 // The platform session_timeout.do sets the login page to welcome.do
 // Since we are handling the login, clear that value
 var session = gs.getSession();
 var nt = session.getProperty("nav_to");
 var sPage = session.getProperty("starting_page");
 if (nt == "welcome.do")
 session.clearProperty("nav_to");
 
 if (!sPage && !nt)
 session.putProperty("starting_page", gs.getProperty("glide.login.home"));
 
 // Send the user to the portal's login page
 var portalGR = new GlideRecord("sp_portal");
 portalGR.addQuery("url_suffix", this.portal.replace(/\//g, ""));
 portalGR.addNotNullQuery("login_page");
 portalGR.query();
 if (portalGR.next())
 return this.portal + "?id=" + portalGR.login_page.id;


// Send to the a default login page
 return this.portal + "?id=login";
 },
 
 /***
 *
 * Referred to by property: glide.entry.first.page.script
 * 
 **/
getFirstPageURL: function() {


var session = gs.getSession();


this.logProperties('before', session);


var check = session.getRoles();
 var rs = check.match(/itil/); //to check if user has itil roles or not



// has roles and is not a Service Portal page - go to UI16
 var nt = session.getProperty("nav_to");
 var isServicePortalURL = new GlideSPScriptable().isServicePortalURL(nt);
 var redirectURL = session.getProperty("login_redirect");
 

 
 if (rs!=null && !redirectURL && !isServicePortalURL)
 return;


 


 


 


// user may have logged in from a frame, the /login_redirect.do page will bust out of it
 if (!redirectURL) {
 // redirectURL is nav_to 
 // if nav_to == "welcome.do" then use starting_page
 var sPage = session.getProperty("starting_page");
 if (sPage && nt == "welcome.do")
 nt = sPage;
 
 // Avoid a redirect loop to the home page
 var ep = gs.getProperty("glide.login.home");
 if (nt) {
 if (ep == nt)
 nt = null;
 }
 // PRB726860: if page is still welcome.do, go to glide.login.home preserving frameset
 if (nt == "welcome.do") {
 session.putProperty("nav_to", ep);
 return;
 }
 
 session.putProperty("login_redirect", nt || "true");
 return "/login_redirect.do?sysparm_stack=no";
 }


session.clearProperty("login_redirect");
 var returnUrl = this.portal;
 if (redirectURL && redirectURL != "true") {
 var spUrl = new GlideSPScriptable().mapUrlToSPUrl(redirectURL);
 returnUrl = spUrl ? this.portal + "?" + spUrl : redirectURL;
 }


this.logProperties('after', session);
 if (!this.logVariables) {
 gs.log('redirectURL: ' + redirectURL);
 gs.log('User: ' + user.getName());
 gs.log('is internal: ' + (!user.hasRoles()));
 gs.log('returnUrl: ' + returnUrl);
 }


return returnUrl;
 },


logProperties: function(beforeOrAfter, session) {
 if (!this.logVariables)
 return; 
 
 gs.log('SPEntryPage: Redirect ------------------------------- ' + beforeOrAfter);
 gs.log('session.starting_page: ' + session.getProperty("starting_page"));
 gs.log('session.nav_to: ' + session.getProperty("nav_to"));
 gs.log('session.login_redirect: ' + session.getProperty("login_redirect"));
 gs.log('gs.fURI: ' + session.getURI());
 },
 
 type: 'SPEntryPage'
};

Vivek,

Unfortunately not. Using this code just logs me in to a blank portal landing page. When I log out of this and log back in again, I am back at the service portal. Still have to close the session to get back to my fulfiller view.

find_real_file.png