SE login fix

PHOTO EMBED

Thu Jan 13 2022 22:57:45 GMT+0000 (UTC)

Saved by @davidpetrey #javascript #smartedit

/* Added for B2C login links */
$("#samlSignInLink,#samlSignInLinkPopUp,#samlSignInLinkHomepage").off('click', function (e) {
	  
});



$("#samlSignInLink,#samlSignInLinkPopUp,#samlSignInLinkHomepage").on('click', function (e) {
	var redirectUrl;
	var currentPath = document.location.pathname == '/error' ? '' : document.location.pathname;
	var queryString = window.location.search;
	if(queryString) {
		redirectUrl = document.location.origin + "/samlsinglesignon/saml" + currentPath + queryString +"&"
	} else {
		redirectUrl = document.location.origin + "/samlsinglesignon/saml" + currentPath + "?"
	}
	if ($('#isDeviceApp').val() == 'true') {
		redirectUrl =redirectUrl + "idp=B2C_1A_signup_signin_SAML_APP_KMSI"
	} else if ($('#isMobileBrowser').val() == 'true') {
		redirectUrl = redirectUrl + "idp=B2C_1A_signup_signin_SAML_MOBILE"
	} else {
		redirectUrl = redirectUrl + "idp=B2C_1A_signup_signin_SAML"
	}
	

	if(window.parent.location.href.indexOf('smartedit') >= 0){
		localStorage.setItem("SE_login", true);
		console.log("set SE_login TRUE")
		window.open(redirectUrl, '_blank');
	}else{
		window.location.href = redirectUrl;
	}

});


if(localStorage.getItem("SE_login") != null && JSON.parse(localStorage.getItem("SE_login")) == true){
	localStorage.setItem("SE_login", false);
	console.log("set SE_login FALSE")

	window.opener.location.reload();
	window.close();
}
content_copyCOPY