diff --git a/blocks/adp-header/adp-header.js b/blocks/adp-header/adp-header.js
index 68444981..7590dd66 100644
--- a/blocks/adp-header/adp-header.js
+++ b/blocks/adp-header/adp-header.js
@@ -106,21 +106,13 @@ function toggleMenu(nav, navSections, forceExpanded = null) {
export default async function decorate(block) {
block.textContent = '';
- // change adp-logo href depending on whether user is logged in
- let logoHome = null;
- if (await window.adobeIMS?.getProfile() != null) {
- logoHome = `${getBaseConfigPath()}/` + 'assets';
- } else {
- logoHome = `${getBaseConfigPath()}/`;
- }
-
// decorate nav DOM
const nav = document.createElement('nav');
nav.id = 'nav';
nav.innerHTML = `
@@ -228,7 +220,8 @@ export default async function decorate(block) {
}
});
- if (!isPublicPage()) {
+ if (await getUserProfile() !== null) {
+ document.querySelector('.adp-logo').href = getBaseConfigPath() + '/assets';
loadSearchField(nav);
await createUserInfo(nav);
initQuickLinks();
diff --git a/scripts/security-imslib.js b/scripts/security-imslib.js
index 10a1ccc8..9c94edeb 100644
--- a/scripts/security-imslib.js
+++ b/scripts/security-imslib.js
@@ -1,6 +1,7 @@
import { loadScript } from './lib-franklin.js';
import { getAdminConfig } from './site-config.js';
import { fetchCached } from './fetch-util.js';
+import { isPublicPage } from './security.js';
let isIMSInitialized = false;
@@ -25,7 +26,7 @@ async function getBearerTokenFromIMS(callWithToken) {
}
if (!isIMSInitialized) {
window.adobeid = {
- client_id: IMSLIB_ENV_CONFIG.clientId,
+ client_id: imsLibConfig.clientId,
scope: IMSLIB_ENV_CONFIG.scope,
locale: 'en_US',
autoValidateToken: true,
@@ -39,8 +40,10 @@ async function getBearerTokenFromIMS(callWithToken) {
}
const token = tokenDetails && tokenDetails.token;
callWithToken(token);
- } else {
- window.adobeIMS.reAuthenticate();
+ return;
+ }
+ if (!isPublicPage()) {
+ window.adobeIMS.reAuthenticate();
}
},
};
@@ -48,9 +51,9 @@ async function getBearerTokenFromIMS(callWithToken) {
// load ims.min.js
await loadScript(IMSLIB_ENV_CONFIG.urls[imsLibConfig.imsEnvironment]);
isIMSInitialized = true;
- } else {
- window.adobeIMS.reAuthenticate();
+ return;
}
+ window.adobeIMS.reAuthenticate();
}
/**
diff --git a/scripts/security.js b/scripts/security.js
index 58885df9..180e8990 100644
--- a/scripts/security.js
+++ b/scripts/security.js
@@ -52,13 +52,13 @@ export function isPublicPage() {
}
export async function checkUserAccess() {
- if (isPublicPage()) {
- return true;
- }
await getBearerToken();
const { imsUserGroup } = await getIMSConfig();
if (imsUserGroup) {
const imsLibSecurityModule = await import('./security-imslib.js');
+ if (isPublicPage()) {
+ return true;
+ }
return await imsLibSecurityModule.isUserInSecurityGroup(imsUserGroup, await getBearerToken());
}
return true;