var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
$(document).ready(function () {
var loginFormConfig = {
rules: {
txtLoginEmail: {
required: true,
email: true
},
txtLoginPassword: "required"
},
messages: {
txtLoginEmail: {
required: "Vul uw e-mail",
email: "Vul een geldig e-mail"
},
txtLoginPassword: "Voer uw wachtwoord"
}
};
var registerFormConfig = {
rules: {
txtRegisterName: "required",
txtRegisterSurname: "required",
txtRegisterEmail: {
required: true,
email: true
},
txtRegisterPassword: {
required: true,
minlength: 8
},
txtRegisterPasswordConfirm: {
equalTo: "#txtRegisterPassword"
}
},
messages: {
txtRegisterName: "Voer je naam in",
txtRegisterSurname: "Voer je achternaam in",
txtRegisterEmail: {
required: "Voer een e-mail",
email: "Vul een geldig e-mail"
},
txtRegisterPassword: {
required: "Voer een wachtwoord in",
minlength: "Het wachtwoord moet uit minimaal 8 tekens bestaan"
},
txtRegisterPasswordConfirm: {
equalTo: "Wachtwoorden komen niet overeen"
}
}
};
$("form").validate({
ignore: ".ignore",
errorClass: "form-error",
rules: __assign(__assign({}, loginFormConfig.rules), registerFormConfig.rules),
messages: __assign(__assign({}, loginFormConfig.messages), registerFormConfig.messages)
});
$('#login-btn').click(function () {
VPreSignIn();
});
$(document).keypress(function (e) {
if (e.which == 13) {
VPreSignIn();
}
});
function VPreSignIn() {
onlyValidateLoginForm();
if (!$('form').valid())
return;
var data = {
sEmail: $("#txtLoginEmail").val(),
sPassword: $("#txtLoginPassword").val(),
bRememberUser: true
};
localStorage.setItem("email", data.sEmail);
VSignIn(data);
}
function onlyValidateLoginForm() {
$("input", "form").addClass("ignore");
$("input", "#login-form").removeClass("ignore");
}
function VSignIn(data) {
var $loginBtn = $('#login-btn');
$loginBtn.prop("disabled", "disabled");
$.ajax({
type: "POST",
url: "/DoLogin.ashx",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
xhrFields: {
withCredentials: true
},
success: function (data) {
if (!data.bError) {
showSuccess("Hallo, " + data.sUserName, "Invoeren in uw account...");
AuthToken.TokenHelper.saveTokenLocalStorage(data.sTokenJWT);
window.location = data.sReturnURL;
}
else {
showError("Error", data.sErrorMessage);
$loginBtn.prop("disabled", false);
}
},
error: function (jqXHR, textStatus) {
if (jqXHR.status === 0) {
showError("Error", "Connection problem");
}
else {
showError("Error", "Unknown problem");
}
$loginBtn.prop("disabled", false);
}
});
}
$('#forgot-password').click(function () {
var oCaptchaForgotPassword;
Swal.fire({
title: "Wachtwoord vergeten?",
html: "Voer uw e-mailadres in en we sturen u een link om het wachtwoord opnieuw in te stellen." + '