1var SSO_SELECTORS = { 2 login: ".sso-login", 3 logout: ".sso-logout" 4}; 5 6var SSO_URLS = { 7 login: "/live/oidc/sso_login.jsp", 8 logoutAction: "/live/oidc/sso_logout_action.jsp", 9 sessionCheck: "/live/oidc/sso_sessioncheck.jsp" 10}; 11 12// Append a cache-busting timestamp parameter to an SSO URL 13function ssoNoCache(url) { 14 return url + (url.indexOf("?") === -1 ? "?" : "&") + "_=" + (new Date()).getTime(); 15} 16 17// Safe sessionStorage helpers (handle browsers that block storage access) 18function ssoStorageGet(key) { try { return sessionStorage.getItem(key); } catch(e) { return null; } } 19function ssoStorageSet(key, val) { try { sessionStorage.setItem(key, val); } catch(e) {} } 20function ssoStorageRemove(key) { try { sessionStorage.removeItem(key); } catch(e) {} } 21 22function ssoLogin() { 23 var thisPage = window.location.href; 24 //console.log("sfLogin, thisPage=" + thisPage); 25 var actionId = $(this).data('actionid'); 26 if (actionId) { 27 if (thisPage.indexOf("?") == -1) { 28 thisPage += "?"; 29 } else { 30 thisPage += "&"; 31 } 32 thisPage += "actionid=" + actionId; 33 } 34 var location = SSO_URLS.login; 35 window.location.assign(ssoNoCache(location + "?url=" + encodeURIComponent(thisPage))); 36} 37 38$(document).ready(function() { 39 40 if (window.location.hash === "#login") { 41 // Remove hash (to avoid the action to be executed again when the user returns to the page) 42 window.location.hash = ""; 43 ssoLogin(); 44 } 45 46 if (window.location.hash === "#logout") { 47 // console.log("logout called: " + window.location.href); 48 // Remove hash (to avoid the action to be executed again when the user returns to the page) 49 window.location.hash = ""; 50 ssoLogout(); 51 } 52 53 // Track users logging in 54 if (window.location.hash === "#loggedin") { 55 // Remove hash (to avoid the action to be executed again when the user returns to the page); 56 window.location.hash = ""; 57 try { 58 dataLayer.push({'event': 'user-logged-in'}); 59 } catch (error) { 60 console.log(error); 61 } 62 } 63 64 // User clicks Login / Register link 65 $(SSO_SELECTORS.login).click(function() { 66 ssoLogin(); 67 }); 68 69 70 // User clicks Logout link 71 $(SSO_SELECTORS.logout).click(function() { 72 ssoLogout(); 73 }); 74 75 76 function redirectToLogoutPage() { 77 var thisPage = window.location.href; 78 thisPage = thisPage.replace("actionid=", "a="); // disable action 79 var location = SSO_URLS.logoutAction + "?url=" + encodeURI(thisPage); 80 // console.log("redirectToLogoutPage: location=" + location); 81 window.location.assign(ssoNoCache(location)); 82 } 83 84 /** 85 * Log out from site 86 **/ 87 function ssoLogout() { 88 // Empty user object 89 window.m_oauthUsr = null; 90 // Disable auto-login 91 if (typeof(Storage) !== "undefined") { 92 localStorage.removeItem("RegUserId"); 93 sessionStorage.removeItem("OauthUsrInfo"); 94 sessionStorage.removeItem("OauthLoginTime"); 95 ssoStorageRemove("ssoSilentAuthTried"); 96 } 97 hideLoginContent(); 98 redirectToLogoutPage(); 99 } 100 101 102 function createLoginIframeOnOtherDomain() { 103/* DISABLE SEP 4, 2022 [BG] 104 console.log("Create sso iframe"); 105 106 if (!$("#SfSsoOutIfrm").length) { 107 var iframe = document.createElement("iframe"); 108 iframe.setAttribute("id", "SfSsoInIfrm"); 109 iframe.style.display = "none"; 110 iframe.src = window.m_otherLoginPage + "#login"; 111 var elt = document.getElementById("PageFooter"); 112 elt.parentNode.insertBefore(iframe, elt); 113 //console.log("createLoginIframeOnOtherDomain: iframe created"); 114 } 115*/ 116 } 117 118 119 // Check if user is logged in 120 function ssoLoginCheck() { 121 // console.log("ssoLoginCheck: start"); 122 if (!window.m_oauthUsr) { 123 if (typeof(Storage) !== "undefined") { 124 if ((sessionStorage.OauthUsrInfo) && (sessionStorage.OauthLoginTime)) { 125 var currentTime = (new Date()).getTime(); 126 var loginTime = sessionStorage.getItem("OauthLoginTime"); 127 // if ((currentTime - loginTime) < 1800000) { // Login max 30 min ago 128 if ((currentTime - loginTime) < 1800000) { // Login max 1 min ago (for testing purposes, should be set to 30 min or more in production) 129 // console.log("ssoLoginCheck: restoring user from sessionStorage"); 130 window.m_oauthUsr = JSON.parse(sessionStorage.getItem("OauthUsrInfo")); 131 showLoginContent(); 132 } else {
133 // console.log("ssoLoginCheck: sessionStorage cache expired"); 134 } 135 } 136 } 137 } 138 if (!window.m_oauthUsr) { 139 // console.log("ssoLoginCheck: no cached user, calling sso_sessioncheck.jsp"); 140 $.ajax({ 141 type: "POST", 142 url: ssoNoCache(SSO_URLS.sessionCheck), 143 data: "url=" + encodeURIComponent(window.location.href), 144 success: function(data) { 145 try { 146 var myData = data.toString().trim(); 147 // console.log("ssoLoginCheck: response=" + myData); 148 if (myData.indexOf("ERROR") == -1) { 149 if (myData.indexOf("SILENT_AUTH:") === 0) { 150 // Silent re-auth: redirect to PING prompt=none URL (only once per tab) 151 if (ssoStorageGet("ssoSilentAuthTried")) { 152 // console.log("ssoLoginCheck: silent auth already tried, not redirecting"); 153 } else { 154 var silentAuthUrl = myData.substring("SILENT_AUTH:".length); 155 // console.log("ssoLoginCheck: SILENT_AUTH, redirecting to " + silentAuthUrl); 156 ssoStorageSet("ssoSilentAuthTried", "1"); 157 window.location.assign(silentAuthUrl); 158 } 159 } else { 160 // Instantiate user object 161 window.m_oauthUsr = JSON.parse(myData); 162 ssoStorageRemove("ssoSilentAuthTried"); 163 // console.log("ssoLoginCheck: user logged in, contactid=" + window.m_oauthUsr.contactid); 164 if (typeof(Storage) !== "undefined") { 165 localStorage.setItem("EMAIL", window.m_oauthUsr.email); 166 localStorage.setItem("RegUserId", window.m_oauthUsr.contactid); 167 if (window.m_oauthUsr.organization) localStorage.setItem("ORGANIZATIONNAME", window.m_oauthUsr.organization); 168 if (window.m_oauthUsr.jobtitle) localStorage.setItem("JOBTITLE", window.m_oauthUsr.jobtitle); 169 localStorage.setItem("DocuAgendaInterestedIds", window.m_oauthUsr.sessionids) 170 if (typeof setInterestedAfterLogin === "function"){ 171 setInterestedAfterLogin(); 172 } 173 sessionStorage.setItem("OauthUsrInfo", myData); 174 sessionStorage.setItem("OauthLoginTime", (new Date()).getTime()); 175 window.dispatchEvent(new Event('ssoInitialized')); 176 } 177 showLoginContent(); 178 if (window.location.href === window.top.location.href) { 179 // Iframe should only be created when page itself is not in iframe 180 // and for auto-login (when window.location.href === window.top.location.href) 181 createLoginIframeOnOtherDomain(); 182 } 183 $('.sf-uid').val(window.m_oauthUsr.salesforceid); 184 // Click action button 185 var thisPage = window.location.href; 186 if (thisPage.indexOf("actionid=") != -1) { 187 var actionId = thisPage.substring(thisPage.indexOf("actionid=") + 9, thisPage.length); 188 // console.log("ssoLoginCheck: triggering actionid=" + actionId); 189 $('#' + actionId).click(); 190 } 191 } 192 } else { 193 // console.log("ssoLoginCheck: ERROR response, user not logged in"); 194 } 195 } catch(err) { 196 // console.log("ERROR receiving data from ssoLoginCheck: " + err); 197 } 198 }, 199 error:function (xhr, ajaxOptions, thrownError) { 200 // console.log("ERROR executing ssoLoginCheck: " + thrownError); 201 } 202 }); 203 } else { 204 // console.log("ssoLoginCheck: user already set on window.m_oauthUsr"); 205 } 206 } 207 208 209 210 function hideLoginContent() { 211 // Hide my account menu etc. 212 $('a.sf-loginregister').parent().show(); 213 $('.login-warning').show(); 214 $('.requestform').hide(); 215 $('a.sf-register').show(); 216 $('.sf-account').hide(); 217 $('.sf-global-link.logout').hide(); 218 $('.show-on-login').hide(); 219 $('.hide-on-login').show(); 220 $('.sf-uid').val(''); 221 222 if (window.self === window.top) { 223 if (window.IIRISTracker){ 224 window.IIRISTracker.clearTrackingUID(); 225 } else { 226 window.addEventListener('trackerLoaded', function(evt){ 227 if(window.IIRISTracker) window.IIRISTracker.clearTrackingUID(); 228 }); 229 } 230 } 231 232 // Hide event specific elements 233 // $('[class*=show-on-login-event-]').hide(); 234 // $('[class*=hide-on-login-event-]').show(); 235 236 } 237 238 239 function showLoginContent() { 240 241 // Hide login/register links and show My Account 242 $('a.sf-loginregister').parent().hide(); 243 $('.login-warning').hide(); 244 $('.requestform').show(); 245 $('a.sf-register').hide(); 246 $('.sf-account').css('display', 'inline-block'); 247 $('.show-on-login').show(); 248 $('.hide-on-login').hide(); 249 setGatedDownloadLinks(); 250 createAccountMenu(); 251 //$('.sf-global-link.logout').show(); 252 253 // Hide event specific elements 254 if (window.m_oauthUsr) { 255 var events = window.m_oauthUsr.eventreg.split(','); 256 257 for (var i = 0; i < events.length; i++) { 258 $('.show-on-login-event-' + events[i]).show(); 259 $('.hide-on-login-event-' + events[i]).hide(); 260 } 261 } 262 263 if ((window.self === window.top) && (window.m_oauthUsr)) { 264 if (window.IIRISTracker){ 265 window.IIRISTracker.setTrackingUID(window.m_oauthUsr.contactid); 266 } else { 267 window.addEventListener('trackerLoaded', function(evt){ 268 if(window.IIRISTracker) window.IIRISTracker.setTrackingUID(window.m_oauthUsr.contactid); 269 }); 270 } 271 } 272 273 } 274 275 276 function setGatedDownloadLinks() {
277 $(".file-download-link").each(function(e) { 278 var fileId = $(this).data("fileid"); 279 if ($("#ResourceFileLink" + fileId)) $(this).attr("href", $("#ResourceFileLink" + fileId).data("filelink")); 280 }); 281 } 282 283 284 function createAccountMenu() { 285 var classname = '', 286 messages = '', 287 nrOfMessages, 288 isIncomplete = false, 289 hasMessages = false; 290 if (window.m_oauthUsr) { 291 $('.account-name').html(window.m_oauthUsr.firstname + ' ' + window.m_oauthUsr.lastname); 292 $('.account-email').html(window.m_oauthUsr.email); 293 $('#account-menu ul li:not(.logout)').remove(); 294 var menuLinks = JSON.parse(getMyAccountMenuLinks()); 295 if (menuLinks) { 296 for (var i = 0, len = menuLinks.length; i < len; i++) { 297 var classname = ''; 298 var messages = ''; 299 $('#account-menu ul').append($('<li class="' + classname + '"><a href="' + menuLinks[i].link + '" style="text-align:left;">' + menuLinks[i].label + messages + '</a></li>')) 300 } 301 } 302 var $logout = $('#account-menu ul li.logout'); 303 if ($logout) $logout.parent().append($logout); 304 if (this.accountHasWarning || isIncomplete) { 305 $('.account').addClass('account-not-verified'); 306 return; 307 } 308 if (hasMessages) { 309 $('.account').append($('<span class="account-msgs">' + nrOfMessages + '</span>')) 310 } 311 } 312 } 313 314 315 function getMyAccountMenuLinks() { 316 var links = '[ '; 317 if (window.m_oauthUsr) { 318 var path = window.location.pathname; 319 if ((path != '') && (path != '/') && (path != '/index.html')) { 320 links += '{ "label": "' + window.m_homepageLink + '", "link": "' + window.m_siteHost + '/" }, '; 321 } 322 links += '{ "label": "My Profile", "link": "' + window.m_siteHost + '/live/console/default.jsp" }'; 323 if ((window.m_oauthUsr.companies) && (window.m_oauthUsr.companies.length > 0)) { 324 links += ', { "label": "Company Profiles", "link": "'+ window.m_siteHost + '/live/console/default.jsp?status=2" }'; 325 } 326 } 327 links += ' ]'; 328 return links; 329 } 330 331 332 ssoLoginCheck(); 333 334 335 $('.grip-profile-link').click(function() { 336 var exhibitionId = parseInt($(this).data('exhibitionid')); 337 var gripId = parseInt($(this).data('gripid')); 338 if ((exhibitionId > 0) && (gripId > 0)) { 339 if (window.m_oauthUsr) { 340 var regIdsStr = "," + window.m_oauthUsr.eventreg + ","; 341 if (regIdsStr.indexOf("," + exhibitionId + ",") != -1) { 342 var location = "https://matchmaking.grip.events/CPhiFestivalofPharma/app/profile/" + gripId + "?badgeid=" + window.m_oauthUsr.salesforceid + "&email=" + window.m_oauthUsr.email + "&auto=true"; 343 //console.log("grip-profile-link, location=" + location); 344 window.location.assign(location); 345 } 346 } 347 } 348 }); 349 350 351 $('.swapcard-profile-link').click(function() { 352 var exhibitionId = parseInt($(this).data('exhibitionid')); 353 var swapcardIdStr = $(this).data('swapcardid'); 354 if ((exhibitionId > 0) && (swapcardIdStr != "")) { 355 if (window.m_oauthUsr) { 356 var regIdsStr = "," + window.m_oauthUsr.eventreg + ","; 357 if (regIdsStr.indexOf("," + exhibitionId + ",") != -1) { 358 //var location = "https://app.swapcard.com/event/cphi-discover-1/exhibitor/" + swapcardIdStr; 359 var location = "https://app.swapcard.com"; 360 //console.log("swapcard-profile-link, location=" + location); 361 window.location.assign(location); 362 } 363 } 364 } 365 }); 366 367 368});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.