MaketRandevu/assets/js/forgot_password.js

46 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

$(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');
$('#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');
$('#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.');
}
2020-12-02 20:57:49 +03:00
});
}
$form.on('submit', onFormSubmit);
});