
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 06:42 AM
We have an issue where users try to access KB Articles before logging in, usually from a direct link someone else sends, and after they log in and successfully authenticate it takes them back to our homepage instead of the KB Article they were on.
We had this same problem a while ago for Catalog Items and successfully routed them back to the item after logging in with SSO Authentication. We used the same logic and scripting for KB Articles, but that doesn't work for this. We put the script below behind the login button in the header, which should be the same on both Items and KB Articles.
Again, this worked for redirection back to Catalog Items but not for redirection back to KB Articles.
Has anyone had this issue, or can think of another route to take?
Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 01:06 PM
Yes. This can be mitigated by checking to see if the URL is navigating to the knowledge table.
You can update your code above like this:
var c=this;
$scope.openLogin = function() {
if (!c.data.is_logged_in) {
/*START GET URL FOR KB ARTICLE*/
var originalURL = $window.location.href; //Get current URL
var kbSubstr = "sys_kb_id";
var redirectToURL, modifiedURL;
if (originalURL.includes(kbSubstr) === true) {//determine if URL is for KB Article
modifiedURL = originalURL.replace("/en", ""); //remove "/en" from the URL
redirectToURL = modifiedURL; //return correct URL
} else {
redirectToURL = originalURL;//set redirect to origin URL
}
/*END GET URL FOR KB ARTICLE*/
c.server.get({
action: "set_sso_destination",
pageURI: redirectToURL //Set URL to return to after login was $window.location.href
}).then(function() {
window.location = "/login_with_sso.do";
});
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 01:06 PM
Yes. This can be mitigated by checking to see if the URL is navigating to the knowledge table.
You can update your code above like this:
var c=this;
$scope.openLogin = function() {
if (!c.data.is_logged_in) {
/*START GET URL FOR KB ARTICLE*/
var originalURL = $window.location.href; //Get current URL
var kbSubstr = "sys_kb_id";
var redirectToURL, modifiedURL;
if (originalURL.includes(kbSubstr) === true) {//determine if URL is for KB Article
modifiedURL = originalURL.replace("/en", ""); //remove "/en" from the URL
redirectToURL = modifiedURL; //return correct URL
} else {
redirectToURL = originalURL;//set redirect to origin URL
}
/*END GET URL FOR KB ARTICLE*/
c.server.get({
action: "set_sso_destination",
pageURI: redirectToURL //Set URL to return to after login was $window.location.href
}).then(function() {
window.location = "/login_with_sso.do";
});
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 06:36 AM
This worked, thank you!