How to setup portal redirection based on different roles


Description

Lets take the below scenario:

SP and CSM are the two portals.

CSM portal is used by the role sn_customerservice.consumer and SP portal is used by other end users (no role).

For admin user and other role based users, they should be landing on the native UI.


Release or Environment

All supported releases

Instructions

This can be achieved by cloning the OOB SPEntryPage. Once the custom script include is created, you need to modify the below system properties:

  • glide.entry.first.page.script - set the value as new NAME_OF_NEW_SCRIPT().getFirstPageURL()
  • glide.entry.page.script - set the value as new NAME_OF_NEW_SCRIPT().getLoginURL()


Modify line 69 as below:

if(user.hasRole('admin'))
{
gs.log("Admin Redirection 1");
return "/?.do";
}
else if (user.hasRoles() && !redirectURL && !isServicePortalURL)
{
gs.log("Redirection 1");
return "/?.do";
}
else if (user.hasRole('sn_customerservice.consumer') && !redirectURL && !isServicePortalURL)
{
gs.log("Redirection 2");
return "/csm";
}
else if(!user.hasRoles() && !redirectURL && !isServicePortalURL)
{
gs.log("Redirection 3");
return "/sp";
}

Additional Information

Here you need to make sure that the hasRole check for admin user should always be the first if condition.

gs.hasRole returns true for any role for an admin user.

This is an expected platform behavior.

Here you want also want all the users to have a common login page, and the redirection should happen after login.

In that case, you can remove the Login Page from the portal records, so that all the users land on login.do

Also, you need to change line 22 on the custom script include from:

this.portal = "/sp/";


to

this.portal = "/login.do";

IMPORTANT - The changes mentioned in this article would come as a customization, and is out of scope of support. These changes should be validated on higher instances to check the compatibility.