forked from mirrors/easyappointments
Code refactoring and improvements for the recovery page.
This commit is contained in:
parent
2451d4d5b7
commit
390d66f8d2
3 changed files with 52 additions and 11 deletions
|
@ -39,6 +39,8 @@
|
||||||
<script src="<?= asset_url('assets/vendor/@fortawesome-fontawesome-free/fontawesome.min.js') ?>"></script>
|
<script src="<?= asset_url('assets/vendor/@fortawesome-fontawesome-free/fontawesome.min.js') ?>"></script>
|
||||||
<script src="<?= asset_url('assets/vendor/@fortawesome-fontawesome-free/solid.min.js') ?>"></script>
|
<script src="<?= asset_url('assets/vendor/@fortawesome-fontawesome-free/solid.min.js') ?>"></script>
|
||||||
<script src="<?= asset_url('assets/js/utils/general_functions.js') ?>"></script>
|
<script src="<?= asset_url('assets/js/utils/general_functions.js') ?>"></script>
|
||||||
|
<script src="<?= asset_url('assets/js/utils/url.js') ?>"></script>
|
||||||
|
<script src="<?= asset_url('assets/js/http/recovery_http_client.js') ?>"></script>
|
||||||
<script src="<?= asset_url('assets/js/pages/recovery.js') ?>"></script>
|
<script src="<?= asset_url('assets/js/pages/recovery.js') ?>"></script>
|
||||||
|
|
||||||
<?php section('scripts') ?>
|
<?php section('scripts') ?>
|
||||||
|
|
41
assets/js/http/recovery_http_client.js
Normal file
41
assets/js/http/recovery_http_client.js
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Easy!Appointments - Open Source Web Scheduler
|
||||||
|
*
|
||||||
|
* @package EasyAppointments
|
||||||
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||||
|
* @copyright Copyright (c) Alex Tselegidis
|
||||||
|
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||||
|
* @link https://easyappointments.org
|
||||||
|
* @since v1.5.0
|
||||||
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recovery HTTP client.
|
||||||
|
*
|
||||||
|
* This module implements the account recovery related HTTP requests.
|
||||||
|
*/
|
||||||
|
App.Http.Recovery = (function () {
|
||||||
|
/**
|
||||||
|
* Perform an account recovery.
|
||||||
|
*
|
||||||
|
* @param {String} username
|
||||||
|
* @param {String} email
|
||||||
|
*
|
||||||
|
* @return {Object}
|
||||||
|
*/
|
||||||
|
function perform(username, email) {
|
||||||
|
const url = App.Utils.Url.siteUrl('recovery/perform');
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
csrf_token: App.Vars.csrf_token,
|
||||||
|
username,
|
||||||
|
email
|
||||||
|
};
|
||||||
|
|
||||||
|
return $.post(url, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
perform
|
||||||
|
};
|
||||||
|
})();
|
|
@ -16,6 +16,9 @@
|
||||||
*/
|
*/
|
||||||
App.Pages.Recovery = (function () {
|
App.Pages.Recovery = (function () {
|
||||||
const $form = $('form');
|
const $form = $('form');
|
||||||
|
const $username = $('#username');
|
||||||
|
const $email = $('#email');
|
||||||
|
const $getNewPassword = $('#get-new-password');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event: Login Button "Click"
|
* Event: Login Button "Click"
|
||||||
|
@ -26,24 +29,19 @@ App.Pages.Recovery = (function () {
|
||||||
function onFormSubmit(event) {
|
function onFormSubmit(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const url = GlobalVariables.baseUrl + '/index.php/recovery/perform';
|
|
||||||
|
|
||||||
const data = {
|
|
||||||
csrf_token: GlobalVariables.csrfToken,
|
|
||||||
username: $('#username').val(),
|
|
||||||
email: $('#email').val()
|
|
||||||
};
|
|
||||||
|
|
||||||
const $alert = $('.alert');
|
const $alert = $('.alert');
|
||||||
|
|
||||||
$alert.addClass('d-none');
|
$alert.addClass('d-none');
|
||||||
|
|
||||||
$('#get-new-password').prop('disabled', true);
|
$getNewPassword.prop('disabled', true);
|
||||||
|
|
||||||
$.post(url, data).done((response) => {
|
const username = $username.val();
|
||||||
|
const email = $email.val();
|
||||||
|
|
||||||
|
App.Http.Recovery.perform(username, email).done((response) => {
|
||||||
$alert.removeClass('d-none alert-danger alert-success');
|
$alert.removeClass('d-none alert-danger alert-success');
|
||||||
|
|
||||||
$('#get-new-password').prop('disabled', false);
|
$getNewPassword.prop('disabled', false);
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
$alert.addClass('alert-success');
|
$alert.addClass('alert-success');
|
||||||
|
|
Loading…
Reference in a new issue