mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-28 10:53:40 +03:00
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
$(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');
|
|
|
|
$alert.addClass('d-none');
|
|
$('#get-new-password').prop('disabled', true);
|
|
|
|
$.post(url, data).done(function (response) {
|
|
$alert.removeClass('d-none alert-danger alert-success');
|
|
$('#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.'
|
|
);
|
|
}
|
|
});
|
|
}
|
|
|
|
$form.on('submit', onFormSubmit);
|
|
});
|