UI Script for portal redirect based on role not working

Garrett2
Tera Expert

I have this UI script

 

(function() {

var isInternal = g_user.hasRole('snc_internal', true);
if(!isInternal) {

var loc = window.location;
//var oldUrl = loc.protocol + "//" + loc.host + loc.pathname + loc.search + loc.hash;
var newUrl = loc.protocol + "//" + loc.host + "/kc" + loc.search + loc.hash;
window.location.replace(newUrl);
}
})();

 it's attached to a theme for my service portal. I would like to redirect users who land on that portal to the /kc portal.

 

(function() {
var loc = window.location;
//var oldUrl = loc.protocol + "//" + loc.host + loc.pathname + loc.search + loc.hash;
var newUrl = loc.protocol + "//" + loc.host + "/kc" + loc.search + loc.hash;
window.location.replace(newUrl);
})();

 This version works with no issues. It's not until I add the conditional statement that I run into issues. Any idea on why that isn't working?