Skip to content

Commit

Permalink
Merge pull request #56 from adobecom/MWPW-158046-redirect-after-login
Browse files Browse the repository at this point in the history
MWPW-158046: Add query param to ims redirect url
  • Loading branch information
zagi25 authored Sep 12, 2024
2 parents 04deb03 + fe6e987 commit 15cdff7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
11 changes: 10 additions & 1 deletion edsdme/scripts/scripts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { applyPagePersonalization } from './personalization.js';
import { setLibs, redirectLoggedinPartner, updateIMSConfig, preloadResources, getRenewBanner, updateNavigation, updateFooter } from './utils.js';
import { setLibs, redirectLoggedinPartner, updateIMSConfig, preloadResources, getRenewBanner, updateNavigation, updateFooter, PARTNER_LOGIN_QUERY } from './utils.js';

// Add project-wide style path here.
const STYLES = '/edsdme/styles/styles.css';
Expand Down Expand Up @@ -47,6 +47,15 @@ const CONFIG = {
}
}());

(function removePartnerLoginQuery() {
const url = new URL(window.location.href);
const { searchParams } = url;
if (searchParams.has(PARTNER_LOGIN_QUERY)) {
searchParams.delete(PARTNER_LOGIN_QUERY);
window.history.replaceState({}, '', url.toString());
}
}());

// Load LCP image immediately
(function loadLCPImage() {
const lcpImg = document.querySelector('img');
Expand Down
11 changes: 7 additions & 4 deletions edsdme/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* The decision engine for where to get Milo's libs from.
*/

export const PARTNER_LOGIN_QUERY = 'partnerLogin';
export const LEVELS = {
REGISTERED: 'registered',
CERTIFIED: 'certified',
Expand Down Expand Up @@ -238,15 +238,18 @@ export function updateIMSConfig() {
if (!window.adobeIMS) return;
clearInterval(imsReady);
let target;
if (!window.adobeIMS.isSignedInUser()) {
const partnerLogin = !window.adobeIMS.isSignedInUser();
if (partnerLogin) {
target = getMetadataContent('adobe-target-after-login');
} else {
target = getMetadataContent('adobe-target-after-logout') ?? getProgramHomePage(window.location.pathname);
}

if (!target) return;
const targetUrl = new URL(window.location);
targetUrl.pathname = target;
partnerLogin && targetUrl.searchParams.set(PARTNER_LOGIN_QUERY, true);
if (target) {
targetUrl.pathname = target;
}
window.adobeIMS.adobeIdData.redirect_uri = targetUrl.toString();
}, 500);
}
Expand Down

0 comments on commit 15cdff7

Please sign in to comment.