2021-12-18 20:25:03 +03:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* 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
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
2022-01-14 11:26:44 +03:00
|
|
|
/**
|
|
|
|
* Account HTTP client.
|
|
|
|
*
|
|
|
|
* This module implements the account related HTTP requests.
|
|
|
|
*/
|
2021-12-18 20:25:03 +03:00
|
|
|
App.Http.Account = (function () {
|
|
|
|
/**
|
|
|
|
* Save account.
|
|
|
|
*
|
|
|
|
* @param {Object} account
|
|
|
|
*
|
2021-12-18 20:34:12 +03:00
|
|
|
* @return {Object}
|
2021-12-18 20:25:03 +03:00
|
|
|
*/
|
|
|
|
function save(account) {
|
|
|
|
const url = App.Utils.Url.siteUrl('account/save');
|
|
|
|
|
|
|
|
const data = {
|
2022-01-18 10:18:22 +03:00
|
|
|
csrf_token: vars('csrf_token'),
|
2021-12-18 20:25:03 +03:00
|
|
|
account
|
|
|
|
};
|
|
|
|
|
|
|
|
return $.post(url, data);
|
|
|
|
}
|
|
|
|
|
2021-12-18 20:55:58 +03:00
|
|
|
/**
|
|
|
|
* Validate username.
|
|
|
|
*
|
2022-01-07 11:23:21 +03:00
|
|
|
* @param {Number} userId
|
2021-12-18 20:55:58 +03:00
|
|
|
* @param {String} username
|
|
|
|
*
|
|
|
|
* @return {Object}
|
|
|
|
*/
|
2022-01-07 11:23:21 +03:00
|
|
|
function validateUsername(userId, username) {
|
2021-12-18 20:55:58 +03:00
|
|
|
const url = App.Utils.Url.siteUrl('account/validate_username');
|
|
|
|
|
|
|
|
const data = {
|
2022-01-18 10:18:22 +03:00
|
|
|
csrf_token: vars('csrf_token'),
|
2022-01-07 11:23:21 +03:00
|
|
|
user_id: userId,
|
2021-12-18 20:55:58 +03:00
|
|
|
username
|
|
|
|
};
|
|
|
|
|
|
|
|
return $.post(url, data);
|
|
|
|
}
|
|
|
|
|
2022-01-17 19:42:47 +03:00
|
|
|
/**
|
|
|
|
* Change language.
|
|
|
|
*
|
|
|
|
* @param {String} language
|
|
|
|
*/
|
|
|
|
function changeLanguage(language) {
|
|
|
|
const url = App.Utils.Url.siteUrl('account/change_language');
|
|
|
|
|
|
|
|
const data = {
|
2022-01-18 10:18:22 +03:00
|
|
|
csrf_token: vars('csrf_token'),
|
2022-01-17 19:42:47 +03:00
|
|
|
language
|
|
|
|
};
|
|
|
|
|
|
|
|
return $.post(url, data);
|
|
|
|
}
|
|
|
|
|
2021-12-18 20:25:03 +03:00
|
|
|
return {
|
2021-12-18 20:55:58 +03:00
|
|
|
save,
|
2022-01-17 19:42:47 +03:00
|
|
|
validateUsername,
|
|
|
|
changeLanguage
|
2021-12-18 20:25:03 +03:00
|
|
|
};
|
|
|
|
})();
|