Skip to content

Commit

Permalink
Issue #CO-824: dynamic redirect URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham Bansal authored and Shubham Bansal committed Mar 13, 2024
1 parent bf876cc commit 463de74
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ansible/artifacts/sunbird/login/resources/js/telemetry_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3159,6 +3159,16 @@ var handleGoogleAuthEvent = () => {
redirectToLib();
}
};

const allowedUrlForRedirect = [
"https://dockstaging.sunbirded.org/sourcing",
"https://dock.sunbirded.org/sourcing",
"https://dock.sunbirded.org/contribute",
"https://dockstaging.sunbirded.org/contribute",
"https://ckoci.sunbirded.org/sourcing",
"https://ckoci.sunbirded.org/contribute"
];

var redirectToPortal = (redirectUrlPath) => { // redirectUrlPath for sso and self signUp
const curUrlObj = window.location;
var redirect_uri = getValueFromSession('redirect_uri');
Expand All @@ -3171,9 +3181,7 @@ var redirectToPortal = (redirectUrlPath) => { // redirectUrlPath for sso and sel
const redirect_uriLocation = new URL(redirect_uri);
if (client_id === 'android' || client_id === 'desktop') {
window.location.href = sessionUrlObj.protocol + '//' + sessionUrlObj.host + redirectUrlPath + updatedQuery;
} else if(client_id === 'portal' &&
redirectUrlPath === '/sign-in/sso/select-org' &&
(redirect_uri.includes('dock.sunbirded.org') || redirect_uri.includes('dockstaging.sunbirded.org'))) {
} else if(client_id === 'portal' && redirectUrlPath === '/sign-in/sso/select-org' && allowedUrlForRedirect.some(allowedUrl => allowedUrl.includes(redirect_uriLocation.host))) {
window.location.href = sessionUrlObj.protocol + '//' + sessionUrlObj.host + redirectUrlPath + updatedQuery;
} else {
window.location.href = redirect_uriLocation.protocol + '//' + redirect_uriLocation.host +
Expand Down

0 comments on commit 463de74

Please sign in to comment.