2020-06-09 02:01:41 +02:00
|
|
|
(function () {
|
|
|
|
var form = document.getElementById('loginForm');
|
|
|
|
|
|
|
|
form.onsubmit = function (e) {
|
|
|
|
document.getElementById('loading').style.visibility = 'visible';
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
var formData = new FormData(form);
|
|
|
|
|
2020-06-13 22:39:44 +02:00
|
|
|
MapGuesser.httpRequest('POST', form.action, function () {
|
2020-06-09 02:01:41 +02:00
|
|
|
if (this.response.error) {
|
|
|
|
var errorText;
|
|
|
|
switch (this.response.error) {
|
|
|
|
case 'user_not_found':
|
2020-06-14 17:16:08 +02:00
|
|
|
errorText = 'No user found with the given email address. You can <a href="/signup" title="Sign up">sign up here</a>!';
|
|
|
|
break;
|
|
|
|
case 'user_not_active':
|
|
|
|
errorText = 'User found with the given email address, but the account is not activated. Please check your email and click on the activation link!';
|
2020-06-09 02:01:41 +02:00
|
|
|
break;
|
|
|
|
case 'password_not_match':
|
|
|
|
errorText = 'The given password is wrong.'
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-06-10 20:22:01 +02:00
|
|
|
document.getElementById('loading').style.visibility = 'hidden';
|
|
|
|
|
2020-06-09 02:01:41 +02:00
|
|
|
var loginFormError = document.getElementById('loginFormError');
|
|
|
|
loginFormError.style.display = 'block';
|
|
|
|
loginFormError.innerHTML = errorText;
|
|
|
|
|
|
|
|
form.elements.email.select();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.location.replace('/');
|
2020-06-13 22:39:44 +02:00
|
|
|
}, formData);
|
2020-06-09 02:01:41 +02:00
|
|
|
};
|
|
|
|
})();
|