There is a piece of code that restricts users from viewing our "pricing popup" until they log in. However, once the user logs in, I want the pricing popup to reappear as if the login never occurred. Ideally, the user shouldn't have to click again to open the popup if it was previously open before logging in.
Unfortunately, PHP cannot be used due to limitations with the web app being utilized. It is essential for the solution to be JavaScript-based. My development environment is Microsoft Visual Studio 2015 and I believe the framework being used is MVC.
I've experimented with rearranging elements to check for syntax errors but to no avail. Additionally, attempting to use location.reload resulted in the same issue where the modal wouldn't display after the refresh.
The current code mandates that the user must log in to access the popup. The problem arises when the popup disappears after the user logs in.
function CheckEmail(e) {
var data = $('#signInForm').serializeArray();
var controller = (typeof CURRENT_CONTROLLER != undefined) ? CURRENT_CONTROLLER : "Home";
ShowHideLoader(true);
if (isValidEmail(data[1]["value"])) {
$.ajax({
url: '/../Account/FindByNameOrEmailAsync',
type: 'POST',
dataType: "json",
data: JSON.stringify({ "usernameOrEmail": data[1]["value"] }),
context: this,
contentType: 'application/json; charset=utf-8',
success: function (data) {
ShowHideLoader(false);
//alert(data);
if (data.status) {
$("#emailCheck").hide();
$("#enterPassword").fadeOut(500, function () {
$('#enterPassword').fadeIn(500);
});
} else {
//$.get("Account/RegisterRedirect", { Email: $("#signin_email").val() });
if (controller == "Business") {
$("#login-modal").modal("hide");
$("#signup-modal").modal('show');
SignupEmail.SetValue($("#signin_email").val());
} else
window.location = data.returnUrl;
}
ShowHideLoader(false);
},
error: function () {
alert("Error! Src: /Account/FindByNameOrEmailAsync");
ShowHideLoader(false);
}
});
} else {
$("#wrongEmail").fadeOut(500, function () {
$('#wrongEmail').fadeIn(500);
});
$("#authInfo").hide();
ShowHideLoader(false);
}
}
function ShowHideLoader(visible) {
if (visible)
$(".signin-preloader").css("visibility", "visible");
else
$(".signin-preloader").css("visibility","hidden");
}
function ShowHideSignUpLoader(visible) {
if (visible)
$(".signup-preloader").css("visibility", "visible");
else
$(".signup-preloader").css("visibility", "hidden");
}
function ValidateForm(data) {
if (data.res) {
...
}
...
//This part checks if the user is signed in. If not, signing in is required to access the popup.
var showPopup;
var showModalForSignIn = function (seePricing) {
$("#login-modal").modal("show");
$("#authInfo").hide();
$("#needSigninMessage").show();
showPopup = seePricing;
}