- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2014 10:47 AM
We already have login rules in place to redirect non-roled users to our CMS. However, we would like to route all users to the CMS -- how? Also, for itil roled users, we would like to have them click on a link from within the CMS and be routed back to the itil view.
For non-roled users, we have a homepage defined for them with a content block that redirects them to the CMS site. We don't want to do that for itil people because we don't want them to be rerouted back to CMS if this click on the link to go to the itil site. Any suggestions?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2014 07:07 AM
Excellent point, yes, if the ITIL user changes their home page, they would bypass your script. A better alternative is to create it as a global UI Script. Try this one out:
UI Script
Name: ESS Redirect
Active: True
Description: Redirects users to the ESS site
Global: True
addLoadEvent(function() {
if (g_user.hasRole('admin') {
// Do nothing if user is admin, this is to allow testing of the script without risk
}
// If user has no roles and they are on a non ESS page
else if (!g_user.hasRoles() && document.URL.indexOf('ess') == -1) {
// Redirect to ESS
window.location = 'https://instancename.service-now.com/ess';
}
// If user has roles, they are on a non ESS page and they were not referred from the ess site
else if (g_user.hasRoles() && document.URL.indexOf('ess') == -1 && top.document.referrer.indexOf('ess') == -1) {
// Redirect to ESS
window.location = 'https://instancename.service-now.com/ess';
}
});
NOTE: Global UI scripts will run on both ITIL site and ESS site. This is why the document.URL.indexOf('ess') is necessary, it prevents redirection from the ESS site to the Ess site.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2015 12:25 PM
Glad to hear it, Lindsey! If you need anything else, let me know
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2016 07:50 AM
You might want to additionally check if the user got impersonated so that the admin who impersonated the user doesn't get redirected automatically.
This could looks somehow like this:
var ga = new GlideAjax('SomeAjaxClass');
ga.addParam('sysparm_name', 'impersonatingUserID');
ga.getXMLWait();
var answer = ga.getAnswer();
if(answer === null){
window.top.location.href = 'YourURL';
}
The Script Include:
var SomeAjaxClass= Class.create();
SomeAjaxClass.prototype = Object.extendsObject(AbstractAjaxProcessor,{
isPublic: function() {
return true;
},
impersonatingUserID: function(){
//returns sys_user.user_name
return gs.getImpersonatingUserName();
},
type: 'SomeAjaxClass'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2018 08:30 AM
Travis,
I might be beating a dead horse.
I am testing the above code in my env't.
What I'm having a problem with is authenticating users with NO ROLE who enter the ess site directly. Ex: https://cxgnow.abc/ess
I've tested it with some users with NO ROLE, but they are not authenticated
Any suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2018 09:01 AM
Hi Matthew,
Sorry, I'm having trouble figuring out which of the above code blocks you are referring to. Can you please let me know which code you are using and walk me through the steps and results that your user is experiencing? If we need to, we can setup some time to screen share and walk through if possible. These redirects are complicated and don't always behave the way you would expect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2018 12:07 PM
Hey Travis,
Thanks for the reply. sorry for the vague reply. Turns out we found the solution to our problem.
The issue was that users w/out a role were not being authenticated when they entered our ESS page.
3 things we did:
1. Ensured the login rule for non roled users was active
2. Created a sys_public page for our site (ess)
3. Deactivated the view_content public page
Seems to work like a champ now
Take care-
Matthew
