Service Portal - Configured SpEntryPage user redirection does not work


Description

When a user logs out from native UI/from any other portal and login again in same browser, the system navigates to the page from where the user logged out, instead of considering the configured SPEntryPage after each login.

Steps to Reproduce

Set the system property glide.entry.first.page.script = new SPEntryPage().getFirstPageURL()

Scenario 1:
1.1. Login the instance with ess user, it redirects to the /sp page
1.2. Manually navigate to /kb page or /cab page
1.3. Logout from /kb or /cab page
1.4. Login in the same browser, it redirects to /kb or /cab page
1.5. In case the banner header shows messed up, refresh the browser (PRB736834/KB0717896).

Scenario 2:
2.1. Login the instance with itil user, it navigates to Platform UI navpage.do
2.2. Manually navigate to /sp page
2.3. Logout from /sp page
2.4. Login in the same browser, it navigates to /nav_to.do?uri=%2Fsp
2.5. Refresh the browser, it navigates to /sp page where the banner displaying properly.

Overall, it will navigate to the page from where user logged out, which seems to contradict the definition of SPEntryPage ("Follow these steps to redirect a user to Service Portal after they log in"):
https://docs.servicenow.com/bundle/madrid-servicenow-platform/page/build/service-portal/concept/c_SPSSOLoginAndRedirects.html

Workaround

This is expected behaviour. When the user is trying to access the platform URL, the SPEntryPage, when configured, will redirect to the platform only if the user has any roles, otherwise it will redirect to the portal.
If the user goes to another portals like /cab or /kb, and then logs out from there, will be landing onto the portal logout page. If the user then logs in from there, will be going to the respective portal page, not /sp.

NOTE: SPEntryPage will come into picture only if users are trying to hit a platform URL.


Related Problem: PRB1363222