2021-12-10 10:41:16 +03:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* Easy!Appointments - Open Source Web Scheduler
|
|
|
|
*
|
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
|
|
|
* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
|
|
|
|
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
* @link http://easyappointments.org
|
|
|
|
* @since v1.5.0
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
const $form = $('form');
|
2020-04-27 21:20:35 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
|
2021-12-10 10:41:16 +03:00
|
|
|
const url = GlobalVariables.baseUrl + '/index.php/recovery/perform';
|
2020-04-27 21:20:35 +03:00
|
|
|
|
2021-12-10 10:41:16 +03:00
|
|
|
const data = {
|
|
|
|
csrfToken: GlobalVariables.csrfToken,
|
|
|
|
username: $('#username').val(),
|
|
|
|
email: $('#email').val()
|
2020-04-27 21:20:35 +03:00
|
|
|
};
|
|
|
|
|
2021-12-10 10:41:16 +03:00
|
|
|
const $alert = $('.alert');
|
2020-04-27 21:20:35 +03:00
|
|
|
|
2020-06-18 21:37:11 +03:00
|
|
|
$alert.addClass('d-none');
|
2021-12-10 10:41:16 +03:00
|
|
|
|
2020-04-27 21:20:35 +03:00
|
|
|
$('#get-new-password').prop('disabled', true);
|
|
|
|
|
2021-12-10 10:41:16 +03:00
|
|
|
$.post(url, data).done((response) => {
|
2021-11-06 19:38:37 +03:00
|
|
|
$alert.removeClass('d-none alert-danger alert-success');
|
2021-12-10 10:41:16 +03:00
|
|
|
|
2021-11-06 19:38:37 +03:00
|
|
|
$('#get-new-password').prop('disabled', false);
|
2021-12-10 10:41:16 +03:00
|
|
|
|
|
|
|
if (response.success) {
|
2021-11-06 19:38:37 +03:00
|
|
|
$alert.addClass('alert-success');
|
2021-12-13 09:52:09 +03:00
|
|
|
$alert.text(App.Lang.new_password_sent_with_email);
|
2021-11-06 19:38:37 +03:00
|
|
|
} 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.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2020-04-27 21:20:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$form.on('submit', onFormSubmit);
|
2021-12-10 10:41:16 +03:00
|
|
|
})();
|