UI script to work automatically without being called

Kevin Paul
Mega Guru

Hi,

 

I have written a UI script to check logged in users' role and if user has a specific role only, then he would be redirected to the Portal page. 

(function() {
    if (window.self === window.top) { 
        if (g_user.hasRoleExactly('user')) {
            var currentURL = window.location.href;
            if (currentURL.includes('.do') && !currentURL.includes('/sp') && !currentURL.includes('/nav_to')) {
                window.location.href = '/esc';
            }
        }
    }

Currently When I set the UI type to ALL, the global checkbox is disabled. So I can't run it automatically on all the pages that user tries to enter in the URL. Is there any way to do this? I am looking to restrict the user to the portal only when user tries to provide a deep link in the URL.

 

KevinPaul_0-1756478164723.png

 

Any help is appreciated. Thanks!

7 REPLIES 7

Not sure if hasRoleExactly() works in server side script, but I tried with role validation in the script include but deep links bypass it.

@Kevin Paul 

 

And work? Could you share how you did it?

KrishnaMohan
Giga Sage

Hi @Kevin Paul 

What is relation between ui script and portal. did you added the ui script to your portal theme?
if yes how ?

Regards,
Krishnamohan