refactor: rename the theme brand and every identifier from AKSRT to Jio
Full-project rename. `git grep -i aksrt` is now empty apart from the
DBMigrator 3.3.0 changelog note that documents the rename itself.
Code identifiers
- PHP namespace AKSRT\ -> Jio\ (composer PSR-4 + 378 declarations)
- global constants AKSRT_* -> JIO_* (VERSION/DIR/URI, PAY_TYPE_*, CAPTCHA_*)
- procedural functions, hooks, options, meta keys, table names,
cookies, query vars, ajax actions and nonces: aksrt_ -> jio_
- text domain aksrt -> jio; Theme Name -> Jio
- JS globals: aksrtData/aksrtAdminData/... -> jioData/jioAdminData/...,
window.AKSRTCaptcha & friends -> window.JioCaptcha, Aksrt* -> Jio*
- Vue components Aks*.vue -> Jio*.vue (15 files renamed + imports)
- CSS classes/data-attrs/custom properties: aksrt- -> jio-
- REST namespace aksrt/v1 -> jio/v1 (incl. payment gateway callbacks)
Storage layer
- DB tables {prefix}aksrt_* -> {prefix}jio_*; SCHEMA_VERSION 3.2.0 -> 3.3.0
so dbDelta creates the new names on install
- widget id_base aksrt_widget_* -> jio_widget_*
- uninstall.php drop list rebuilt from the actual migrator tables
(dropped 3 stale entries, added the 17 missing ones)
Removed
- hardcoded https://api.aksrt.com/version.json default update endpoint;
get_endpoint() now reads the 「更新端点」 setting and do_check() no-ops
when it is empty
Files renamed: inc/helpers/aksrt-*.php -> jio-*.php (54),
assets/admin/src/components/form/Aks*.vue -> Jio*.vue (15).
Build artifacts regenerated: assets/css/build, assets/js/runtime,
assets/admin/build.
Verified: audit-psr4-paths errors=0, audit-admin-contracts errors=0
(warnings=56, unchanged baseline), 813/813 widget-system tests,
44/44 phpunit, php -l clean across all PHP.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
5b16bc6e15
commit
35bb96e82f
997 files changed
+28216
-28188
No files matched your search
@@ -2,48 +2,48 @@
|
||||
/** User profile and account settings AJAX handlers. */
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if (!function_exists('aksrt_account_captcha_error_data')) {
|
||||
function aksrt_account_captcha_error_data($result): array {
|
||||
if (!function_exists('jio_account_captcha_error_data')) {
|
||||
function jio_account_captcha_error_data($result): array {
|
||||
return [
|
||||
'code' => is_wp_error($result) ? ($result->get_error_code() ?: 'aksrt_captcha_failed') : 'aksrt_captcha_failed',
|
||||
'code' => is_wp_error($result) ? ($result->get_error_code() ?: 'jio_captcha_failed') : 'jio_captcha_failed',
|
||||
'message' => is_wp_error($result)
|
||||
? ($result->get_error_message() ?: __('人机验证失败,请重试', 'aksrt'))
|
||||
: __('人机验证失败,请重试', 'aksrt'),
|
||||
? ($result->get_error_message() ?: __('人机验证失败,请重试', 'jio'))
|
||||
: __('人机验证失败,请重试', 'jio'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
add_action('wp_ajax_aksrt_save_profile', function (): void {
|
||||
add_action('wp_ajax_jio_save_profile', function (): void {
|
||||
if (
|
||||
!isset($_POST['_profile_nonce'])
|
||||
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_profile_nonce'])), 'aksrt_profile_save')
|
||||
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_profile_nonce'])), 'jio_profile_save')
|
||||
) {
|
||||
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'jio')]);
|
||||
}
|
||||
|
||||
$user_id = (int) ($_POST['user_id'] ?? 0);
|
||||
$result = function_exists('aksrt_save_user_center_profile')
|
||||
? aksrt_save_user_center_profile($user_id, $_POST)
|
||||
: new WP_Error('aksrt_profile_unavailable', __('保存失败', 'aksrt'));
|
||||
$result = function_exists('jio_save_user_center_profile')
|
||||
? jio_save_user_center_profile($user_id, $_POST)
|
||||
: new WP_Error('jio_profile_unavailable', __('保存失败', 'jio'));
|
||||
|
||||
if (is_wp_error($result)) wp_send_json_error(['message' => $result->get_error_message()]);
|
||||
wp_send_json_success(['message' => __('保存成功!', 'aksrt')]);
|
||||
wp_send_json_success(['message' => __('保存成功!', 'jio')]);
|
||||
});
|
||||
|
||||
function aksrt_account_code_key(int $user_id, string $scene, string $target): string {
|
||||
return 'aksrt_account_code_' . $user_id . '_' . sanitize_key($scene) . '_' . md5(strtolower(trim($target)));
|
||||
function jio_account_code_key(int $user_id, string $scene, string $target): string {
|
||||
return 'jio_account_code_' . $user_id . '_' . sanitize_key($scene) . '_' . md5(strtolower(trim($target)));
|
||||
}
|
||||
|
||||
function aksrt_account_store_code(int $user_id, string $scene, string $target, string $code): void {
|
||||
function jio_account_store_code(int $user_id, string $scene, string $target, string $code): void {
|
||||
set_transient(
|
||||
aksrt_account_code_key($user_id, $scene, $target),
|
||||
jio_account_code_key($user_id, $scene, $target),
|
||||
['hash' => wp_hash_password($code), 'attempts' => 0],
|
||||
5 * MINUTE_IN_SECONDS
|
||||
);
|
||||
}
|
||||
|
||||
function aksrt_account_consume_code(int $user_id, string $scene, string $target, string $code, bool $consume = true): bool {
|
||||
$key = aksrt_account_code_key($user_id, $scene, $target);
|
||||
function jio_account_consume_code(int $user_id, string $scene, string $target, string $code, bool $consume = true): bool {
|
||||
$key = jio_account_code_key($user_id, $scene, $target);
|
||||
$stored = get_transient($key);
|
||||
if (!is_array($stored) || empty($stored['hash'])) {
|
||||
return false;
|
||||
@@ -67,20 +67,20 @@ function aksrt_account_consume_code(int $user_id, string $scene, string $target,
|
||||
return true;
|
||||
}
|
||||
|
||||
function aksrt_account_proof_key(int $user_id, string $kind): string {
|
||||
return 'aksrt_account_proof_' . sanitize_key($kind) . '_' . $user_id;
|
||||
function jio_account_proof_key(int $user_id, string $kind): string {
|
||||
return 'jio_account_proof_' . sanitize_key($kind) . '_' . $user_id;
|
||||
}
|
||||
|
||||
function aksrt_account_set_proof(int $user_id, string $kind, string $target): void {
|
||||
function jio_account_set_proof(int $user_id, string $kind, string $target): void {
|
||||
set_transient(
|
||||
aksrt_account_proof_key($user_id, $kind),
|
||||
jio_account_proof_key($user_id, $kind),
|
||||
['target' => strtolower(trim($target))],
|
||||
30 * MINUTE_IN_SECONDS
|
||||
);
|
||||
}
|
||||
|
||||
function aksrt_account_consume_proof(int $user_id, string $kind, string $target, bool $consume = true): bool {
|
||||
$key = aksrt_account_proof_key($user_id, $kind);
|
||||
function jio_account_consume_proof(int $user_id, string $kind, string $target, bool $consume = true): bool {
|
||||
$key = jio_account_proof_key($user_id, $kind);
|
||||
$proof = get_transient($key);
|
||||
if (!is_array($proof) || strtolower(trim((string) ($proof['target'] ?? ''))) !== strtolower(trim($target))) {
|
||||
return false;
|
||||
@@ -92,170 +92,170 @@ function aksrt_account_consume_proof(int $user_id, string $kind, string $target,
|
||||
return true;
|
||||
}
|
||||
|
||||
function aksrt_account_email_verification_required(): bool {
|
||||
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
|
||||
function jio_account_email_verification_required(): bool {
|
||||
$settings = class_exists('\Jio\Settings\Settings') ? \Jio\Settings\Settings::get_all() : [];
|
||||
return !empty($settings['email_set_captch']);
|
||||
}
|
||||
|
||||
add_action('wp_ajax_aksrt_send_account_email_code', function (): void {
|
||||
add_action('wp_ajax_jio_send_account_email_code', function (): void {
|
||||
if (
|
||||
!isset($_POST['_settings_nonce'])
|
||||
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'aksrt_account_settings')
|
||||
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'jio_account_settings')
|
||||
) {
|
||||
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'jio')]);
|
||||
}
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$user = wp_get_current_user();
|
||||
if (!$user_id || !($user instanceof WP_User)) {
|
||||
wp_send_json_error(['message' => __('请先登录', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('请先登录', 'jio')]);
|
||||
}
|
||||
|
||||
$scene = sanitize_key((string) wp_unslash($_POST['scene'] ?? ''));
|
||||
if (!in_array($scene, ['verify_email', 'change_email'], true)) {
|
||||
wp_send_json_error(['message' => __('无效的验证场景', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('无效的验证场景', 'jio')]);
|
||||
}
|
||||
if (!aksrt_account_email_verification_required()) {
|
||||
wp_send_json_error(['message' => __('邮箱验证码验证未开启', 'aksrt')]);
|
||||
if (!jio_account_email_verification_required()) {
|
||||
wp_send_json_error(['message' => __('邮箱验证码验证未开启', 'jio')]);
|
||||
}
|
||||
|
||||
$target = $scene === 'verify_email'
|
||||
? (string) $user->user_email
|
||||
: sanitize_email((string) wp_unslash($_POST['new_email'] ?? ''));
|
||||
if (!is_email($target)) {
|
||||
wp_send_json_error(['message' => __('邮箱格式错误', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('邮箱格式错误', 'jio')]);
|
||||
}
|
||||
if ($scene === 'change_email') {
|
||||
if (strtolower($target) === strtolower((string) $user->user_email)) {
|
||||
wp_send_json_error(['message' => __('修改邮箱不能与现邮箱相同', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('修改邮箱不能与现邮箱相同', 'jio')]);
|
||||
}
|
||||
if (email_exists($target)) {
|
||||
wp_send_json_error(['message' => __('该邮箱已有绑定账号', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('该邮箱已有绑定账号', 'jio')]);
|
||||
}
|
||||
}
|
||||
|
||||
if (function_exists('aksrt_require_captcha')) {
|
||||
$captcha = aksrt_require_captcha('change_email', wp_unslash($_POST));
|
||||
if (function_exists('jio_require_captcha')) {
|
||||
$captcha = jio_require_captcha('change_email', wp_unslash($_POST));
|
||||
if ($captcha !== true) {
|
||||
wp_send_json_error(aksrt_account_captcha_error_data($captcha));
|
||||
wp_send_json_error(jio_account_captcha_error_data($captcha));
|
||||
}
|
||||
}
|
||||
if (class_exists('\AKSRT\Extensions\SendLimit')) {
|
||||
$limit = \AKSRT\Extensions\SendLimit::check($target);
|
||||
if (class_exists('\Jio\Extensions\SendLimit')) {
|
||||
$limit = \Jio\Extensions\SendLimit::check($target);
|
||||
if (empty($limit['ok'])) {
|
||||
wp_send_json_error(['message' => (string) $limit['message']]);
|
||||
}
|
||||
}
|
||||
|
||||
$code = str_pad((string) random_int(0, 999999), 6, '0', STR_PAD_LEFT);
|
||||
$sent = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::send_event_email('change_code', $target, [
|
||||
$sent = class_exists('\Jio\Settings\Settings')
|
||||
? \Jio\Settings\Settings::send_event_email('change_code', $target, [
|
||||
'{username}' => $user->display_name,
|
||||
'{site_name}' => get_bloginfo('name'),
|
||||
'{code}' => $code,
|
||||
])
|
||||
: false;
|
||||
if (!$sent) {
|
||||
wp_send_json_error(['message' => __('验证码邮件发送失败,请稍后重试', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('验证码邮件发送失败,请稍后重试', 'jio')]);
|
||||
}
|
||||
|
||||
$cooldown = class_exists('\AKSRT\Extensions\SendLimit') ? (int) \AKSRT\Extensions\SendLimit::record($target) : 0;
|
||||
aksrt_account_store_code($user_id, $scene, $target, $code);
|
||||
$cooldown = class_exists('\Jio\Extensions\SendLimit') ? (int) \Jio\Extensions\SendLimit::record($target) : 0;
|
||||
jio_account_store_code($user_id, $scene, $target, $code);
|
||||
wp_send_json_success([
|
||||
'message' => $scene === 'verify_email'
|
||||
? __('验证码已发送到您的老邮箱', 'aksrt')
|
||||
: __('验证码已发送到新邮箱', 'aksrt'),
|
||||
? __('验证码已发送到您的老邮箱', 'jio')
|
||||
: __('验证码已发送到新邮箱', 'jio'),
|
||||
'countdown' => $cooldown > 0 ? $cooldown : 60,
|
||||
]);
|
||||
});
|
||||
|
||||
add_action('wp_ajax_aksrt_verify_account_email', function (): void {
|
||||
add_action('wp_ajax_jio_verify_account_email', function (): void {
|
||||
if (
|
||||
!isset($_POST['_settings_nonce'])
|
||||
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'aksrt_account_settings')
|
||||
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'jio_account_settings')
|
||||
) {
|
||||
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'jio')]);
|
||||
}
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$user = wp_get_current_user();
|
||||
if (!$user_id || !($user instanceof WP_User) || !is_email((string) $user->user_email)) {
|
||||
wp_send_json_error(['message' => __('当前账号未绑定有效邮箱', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('当前账号未绑定有效邮箱', 'jio')]);
|
||||
}
|
||||
if (!aksrt_account_email_verification_required()) {
|
||||
wp_send_json_error(['message' => __('邮箱验证码验证未开启', 'aksrt')]);
|
||||
if (!jio_account_email_verification_required()) {
|
||||
wp_send_json_error(['message' => __('邮箱验证码验证未开启', 'jio')]);
|
||||
}
|
||||
if (function_exists('aksrt_require_captcha')) {
|
||||
$captcha = aksrt_require_captcha('change_email', wp_unslash($_POST));
|
||||
if (function_exists('jio_require_captcha')) {
|
||||
$captcha = jio_require_captcha('change_email', wp_unslash($_POST));
|
||||
if ($captcha !== true) {
|
||||
wp_send_json_error(aksrt_account_captcha_error_data($captcha));
|
||||
wp_send_json_error(jio_account_captcha_error_data($captcha));
|
||||
}
|
||||
}
|
||||
|
||||
$code = sanitize_text_field((string) wp_unslash($_POST['code'] ?? ''));
|
||||
if (!aksrt_account_consume_code($user_id, 'verify_email', (string) $user->user_email, $code)) {
|
||||
if (class_exists('\AKSRT\Extensions\SecurityHardening')) {
|
||||
\AKSRT\Extensions\SecurityHardening::error_frequency_record();
|
||||
if (!jio_account_consume_code($user_id, 'verify_email', (string) $user->user_email, $code)) {
|
||||
if (class_exists('\Jio\Extensions\SecurityHardening')) {
|
||||
\Jio\Extensions\SecurityHardening::error_frequency_record();
|
||||
}
|
||||
wp_send_json_error(['message' => __('验证码错误或已过期', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('验证码错误或已过期', 'jio')]);
|
||||
}
|
||||
|
||||
if (class_exists('\AKSRT\Extensions\SecurityHardening')) {
|
||||
\AKSRT\Extensions\SecurityHardening::error_frequency_clear();
|
||||
if (class_exists('\Jio\Extensions\SecurityHardening')) {
|
||||
\Jio\Extensions\SecurityHardening::error_frequency_clear();
|
||||
}
|
||||
aksrt_account_set_proof($user_id, 'email_old', (string) $user->user_email);
|
||||
wp_send_json_success(['message' => __('验证成功', 'aksrt')]);
|
||||
jio_account_set_proof($user_id, 'email_old', (string) $user->user_email);
|
||||
wp_send_json_success(['message' => __('验证成功', 'jio')]);
|
||||
});
|
||||
|
||||
add_action('wp_ajax_aksrt_change_password', function (): void {
|
||||
add_action('wp_ajax_jio_change_password', function (): void {
|
||||
if (
|
||||
!isset($_POST['_settings_nonce'])
|
||||
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'aksrt_account_settings')
|
||||
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'jio_account_settings')
|
||||
) {
|
||||
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'jio')]);
|
||||
}
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
if (!$user_id) {
|
||||
wp_send_json_error(['message' => __('请先登录', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('请先登录', 'jio')]);
|
||||
}
|
||||
$user = get_userdata($user_id);
|
||||
if (!($user instanceof WP_User)) {
|
||||
wp_send_json_error(['message' => __('账号信息读取失败,请刷新页面重试', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('账号信息读取失败,请刷新页面重试', 'jio')]);
|
||||
}
|
||||
|
||||
$oauth_new = (bool) get_user_meta($user_id, 'oauth_new', true);
|
||||
$password = trim((string) wp_unslash($_POST['password'] ?? ''));
|
||||
$password2 = trim((string) wp_unslash($_POST['password2'] ?? ''));
|
||||
if (function_exists('aksrt_require_captcha')) {
|
||||
$captcha = aksrt_require_captcha('change_password', wp_unslash($_POST));
|
||||
if (function_exists('jio_require_captcha')) {
|
||||
$captcha = jio_require_captcha('change_password', wp_unslash($_POST));
|
||||
if ($captcha !== true) {
|
||||
wp_send_json_error(aksrt_account_captcha_error_data($captcha));
|
||||
wp_send_json_error(jio_account_captcha_error_data($captcha));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$oauth_new) {
|
||||
$old_password = trim((string) wp_unslash($_POST['passwordold'] ?? ''));
|
||||
if ($old_password === '') {
|
||||
wp_send_json_error(['message' => __('请输入原密码', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('请输入原密码', 'jio')]);
|
||||
}
|
||||
if ($old_password === $password) {
|
||||
wp_send_json_error(['message' => __('新密码和原密码不能相同', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('新密码和原密码不能相同', 'jio')]);
|
||||
}
|
||||
if (class_exists('\AKSRT\Extensions\SecurityHardening') && ($wait = \AKSRT\Extensions\SecurityHardening::error_frequency_wait()) > 0) {
|
||||
wp_send_json_error(['message' => sprintf(__('验证错误次数过多,请 %d 秒后再试', 'aksrt'), $wait)]);
|
||||
if (class_exists('\Jio\Extensions\SecurityHardening') && ($wait = \Jio\Extensions\SecurityHardening::error_frequency_wait()) > 0) {
|
||||
wp_send_json_error(['message' => sprintf(__('验证错误次数过多,请 %d 秒后再试', 'jio'), $wait)]);
|
||||
}
|
||||
if (!wp_check_password($old_password, $user->user_pass, $user_id)) {
|
||||
if (class_exists('\AKSRT\Extensions\SecurityHardening')) {
|
||||
\AKSRT\Extensions\SecurityHardening::error_frequency_record();
|
||||
if (class_exists('\Jio\Extensions\SecurityHardening')) {
|
||||
\Jio\Extensions\SecurityHardening::error_frequency_record();
|
||||
}
|
||||
wp_send_json_error(['message' => __('原密码错误', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('原密码错误', 'jio')]);
|
||||
}
|
||||
}
|
||||
|
||||
$valid = class_exists('\AKSRT\Auth\Service')
|
||||
? \AKSRT\Auth\Service::validate_password($password, $password2)
|
||||
: __('认证服务不可用', 'aksrt');
|
||||
$valid = class_exists('\Jio\Auth\Service')
|
||||
? \Jio\Auth\Service::validate_password($password, $password2)
|
||||
: __('认证服务不可用', 'jio');
|
||||
if ($valid !== true) {
|
||||
wp_send_json_error(['message' => (string) $valid]);
|
||||
}
|
||||
@@ -266,65 +266,65 @@ add_action('wp_ajax_aksrt_change_password', function (): void {
|
||||
}
|
||||
|
||||
delete_user_meta($user_id, 'oauth_new');
|
||||
if (class_exists('\AKSRT\Extensions\SecurityHardening')) {
|
||||
\AKSRT\Extensions\SecurityHardening::error_frequency_clear();
|
||||
if (class_exists('\Jio\Extensions\SecurityHardening')) {
|
||||
\Jio\Extensions\SecurityHardening::error_frequency_clear();
|
||||
}
|
||||
wp_send_json_success([
|
||||
'message' => $oauth_new
|
||||
? __('密码设置成功', 'aksrt')
|
||||
: __('修改成功,下次请使用新密码登录', 'aksrt'),
|
||||
? __('密码设置成功', 'jio')
|
||||
: __('修改成功,下次请使用新密码登录', 'jio'),
|
||||
'reload' => true,
|
||||
]);
|
||||
});
|
||||
|
||||
add_action('wp_ajax_aksrt_change_email', function (): void {
|
||||
add_action('wp_ajax_jio_change_email', function (): void {
|
||||
if (
|
||||
!isset($_POST['_settings_nonce'])
|
||||
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'aksrt_account_settings')
|
||||
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_settings_nonce'])), 'jio_account_settings')
|
||||
) {
|
||||
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('安全验证失败,请刷新页面重试', 'jio')]);
|
||||
}
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$user = wp_get_current_user();
|
||||
if (!$user_id || !($user instanceof WP_User)) {
|
||||
wp_send_json_error(['message' => __('请先登录', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('请先登录', 'jio')]);
|
||||
}
|
||||
|
||||
$new_email = sanitize_email((string) wp_unslash($_POST['new_email'] ?? ''));
|
||||
if (!is_email($new_email)) {
|
||||
wp_send_json_error(['message' => __('邮箱格式错误', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('邮箱格式错误', 'jio')]);
|
||||
}
|
||||
if ($user->user_email !== '' && strtolower($new_email) === strtolower((string) $user->user_email)) {
|
||||
wp_send_json_error(['message' => __('修改邮箱不能与现邮箱相同', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('修改邮箱不能与现邮箱相同', 'jio')]);
|
||||
}
|
||||
if (email_exists($new_email)) {
|
||||
wp_send_json_error(['message' => __('该邮箱已有绑定账号', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('该邮箱已有绑定账号', 'jio')]);
|
||||
}
|
||||
|
||||
$agreement = function_exists('aksrt_get_auth_agreement_view') ? aksrt_get_auth_agreement_view() : ['enabled' => false, 'required' => false];
|
||||
$agreement = function_exists('jio_get_auth_agreement_view') ? jio_get_auth_agreement_view() : ['enabled' => false, 'required' => false];
|
||||
if (!empty($agreement['required']) && empty($_POST['agree_terms'])) {
|
||||
wp_send_json_error(['message' => __('请先同意相关协议', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('请先同意相关协议', 'jio')]);
|
||||
}
|
||||
if (function_exists('aksrt_require_captcha')) {
|
||||
$captcha = aksrt_require_captcha('change_email', wp_unslash($_POST));
|
||||
if (function_exists('jio_require_captcha')) {
|
||||
$captcha = jio_require_captcha('change_email', wp_unslash($_POST));
|
||||
if ($captcha !== true) {
|
||||
wp_send_json_error(aksrt_account_captcha_error_data($captcha));
|
||||
wp_send_json_error(jio_account_captcha_error_data($captcha));
|
||||
}
|
||||
}
|
||||
|
||||
$verification_required = aksrt_account_email_verification_required();
|
||||
$verification_required = jio_account_email_verification_required();
|
||||
$old_email = (string) $user->user_email;
|
||||
if (
|
||||
$old_email !== ''
|
||||
&& $verification_required
|
||||
&& !aksrt_account_consume_proof($user_id, 'email_old', $old_email, false)
|
||||
&& !jio_account_consume_proof($user_id, 'email_old', $old_email, false)
|
||||
) {
|
||||
wp_send_json_error(['message' => __('请先验证老邮箱', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('请先验证老邮箱', 'jio')]);
|
||||
}
|
||||
if (
|
||||
$verification_required
|
||||
&& !aksrt_account_consume_code(
|
||||
&& !jio_account_consume_code(
|
||||
$user_id,
|
||||
'change_email',
|
||||
$new_email,
|
||||
@@ -332,29 +332,29 @@ add_action('wp_ajax_aksrt_change_email', function (): void {
|
||||
false
|
||||
)
|
||||
) {
|
||||
if (class_exists('\AKSRT\Extensions\SecurityHardening')) {
|
||||
\AKSRT\Extensions\SecurityHardening::error_frequency_record();
|
||||
if (class_exists('\Jio\Extensions\SecurityHardening')) {
|
||||
\Jio\Extensions\SecurityHardening::error_frequency_record();
|
||||
}
|
||||
wp_send_json_error(['message' => __('验证码错误或已过期', 'aksrt')]);
|
||||
wp_send_json_error(['message' => __('验证码错误或已过期', 'jio')]);
|
||||
}
|
||||
|
||||
$result = wp_update_user(['ID' => $user_id, 'user_email' => $new_email]);
|
||||
if (is_wp_error($result)) {
|
||||
wp_send_json_error(['message' => $result->get_error_message() ?: __('邮箱更新失败,请稍后重试', 'aksrt')]);
|
||||
wp_send_json_error(['message' => $result->get_error_message() ?: __('邮箱更新失败,请稍后重试', 'jio')]);
|
||||
}
|
||||
|
||||
if ($old_email !== '' && $verification_required) {
|
||||
delete_transient(aksrt_account_proof_key($user_id, 'email_old'));
|
||||
delete_transient(jio_account_proof_key($user_id, 'email_old'));
|
||||
}
|
||||
if ($verification_required) {
|
||||
delete_transient(aksrt_account_code_key($user_id, 'change_email', $new_email));
|
||||
delete_transient(jio_account_code_key($user_id, 'change_email', $new_email));
|
||||
}
|
||||
if (class_exists('\AKSRT\Extensions\SecurityHardening')) {
|
||||
\AKSRT\Extensions\SecurityHardening::error_frequency_clear();
|
||||
if (class_exists('\Jio\Extensions\SecurityHardening')) {
|
||||
\Jio\Extensions\SecurityHardening::error_frequency_clear();
|
||||
}
|
||||
update_user_meta($user_id, 'aksrt_email_verified', 1);
|
||||
if ($old_email !== '' && is_email($old_email) && class_exists('\AKSRT\Settings\Settings')) {
|
||||
\AKSRT\Settings\Settings::send_event_email('change_notice', $old_email, [
|
||||
update_user_meta($user_id, 'jio_email_verified', 1);
|
||||
if ($old_email !== '' && is_email($old_email) && class_exists('\Jio\Settings\Settings')) {
|
||||
\Jio\Settings\Settings::send_event_email('change_notice', $old_email, [
|
||||
'{username}' => $user->display_name,
|
||||
'{site_name}' => get_bloginfo('name'),
|
||||
'{new_email}' => $new_email,
|
||||
@@ -362,7 +362,7 @@ add_action('wp_ajax_aksrt_change_email', function (): void {
|
||||
}
|
||||
|
||||
wp_send_json_success([
|
||||
'message' => $old_email !== '' ? __('邮箱修改成功', 'aksrt') : __('邮箱绑定成功', 'aksrt'),
|
||||
'message' => $old_email !== '' ? __('邮箱修改成功', 'jio') : __('邮箱绑定成功', 'jio'),
|
||||
'reload' => true,
|
||||
]);
|
||||
});
|
||||
Reference in new issue
Block a user