2020-04-27 21:20:35 +03:00
|
|
|
$(function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var $form = $('form');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Event: Login Button "Click"
|
|
|
|
*
|
|
|
|
* Make an HTTP request to the server and check whether the user's credentials are right. If yes then redirect the
|
|
|
|
* user to the destination page, otherwise display an error message.
|
|
|
|
*/
|
|
|
|
function onFormSubmit(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
var url = GlobalVariables.baseUrl + '/index.php/user/ajax_forgot_password';
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
'csrfToken': GlobalVariables.csrfToken,
|
|
|
|
'username': $('#username').val(),
|
|
|
|
'email': $('#email').val()
|
|
|
|
};
|
|
|
|
|
|
|
|
var $alert = $('.alert');
|
|
|
|
|
2020-06-18 21:37:11 +03:00
|
|
|
$alert.addClass('d-none');
|
2020-04-27 21:20:35 +03:00
|
|
|
$('#get-new-password').prop('disabled', true);
|
|
|
|
|
|
|
|
$.post(url, data)
|
|
|
|
.done(function (response) {
|
2020-06-18 21:37:11 +03:00
|
|
|
$alert.removeClass('d-none alert-danger alert-success');
|
2020-04-27 21:20:35 +03:00
|
|
|
$('#get-new-password').prop('disabled', false);
|
|
|
|
if (response === GlobalVariables.AJAX_SUCCESS) {
|
|
|
|
$alert.addClass('alert-success');
|
|
|
|
$alert.text(EALang['new_password_sent_with_email']);
|
|
|
|
} else {
|
|
|
|
$alert.addClass('alert-danger');
|
|
|
|
$alert.text('The operation failed! Please enter a valid username '
|
|
|
|
+ 'and email address in order to get a new password.');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.fail(GeneralFunctions.ajaxFailureHandler);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$form.on('submit', onFormSubmit);
|
|
|
|
});
|