Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

User should redirect to common login page after log out

Gulfam
Giga Guru

Hi Experts

I have a requirement regarding portal routing that I need some help.


The requirement is as follows:

If a user belongs to Company "ABC," they should be routed to the Service Portal (SP).
If a user belongs to Company "XYZ," they should be routed to the Customer Service Management (CSM) Portal.
if user logged out then they should redirected to common login page

 

I have made changes to SPEntryPage script include where I set 'this.portal = "/sp/";' in initialize function. and write a following code in getFirstPageURL function.

 

if (user.hasRole("admin") && !redirectURL && !isServicePortalURL)
return;

 

var userId = gs.getUserID();
var userRec = new GlideRecord('sys_user');
userRec.addEncodedQuery('sys_class_name=customer_contact^ORsys_class_name=sys_user^company.nameINBoxeo,Cambrian,Shark Hotels^sys_id=' + userId);
userRec.query();
if (userRec.next()) {
            this.portal = "/csm/";
        } else {
            this.portal = "/sp/";
        }


To redirect them on common login page i have made changes to System Definition - Installation Exits - logout
i have set hard code value it is working fine with normal user but when a contact log out then they redirected to csm login page

 

gs.include("PrototypeServer");
var Logout = Class.create();
Logout.prototype = {

process: function() {
        // var s = request.getParameter('sysparm_goto_url');
        var localLoginMethod = request.getSession().getAttribute("glide.authenticate.local.login.method");
        if (localLoginMethod == "certificate") {
            if (s)
                response.sendRedirect("logout_certificate_complete.do?sysparm_goto_url=" + s);
            else
                response.sendRedirect("logout_certificate_complete.do");
            return true;
        }
        if (s && GlideSecurityUtils.isURLWhiteListedStrict(s))
            response.sendRedirect(s);
        else
            response.sendRedirect("logout_success.do");
        return true;
    }
}
0 REPLIES 0