登录注册体系的源码级硬切换
This commit is contained in:
1 parent
73fcd4ed72
commit
af52f9e94d
72 files changed
+1666
-6576
No files matched your search
@@ -1,145 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Template Name: AKSRT - Bind Account
|
||||
* Template Post Type: page
|
||||
*
|
||||
* Theme auth route template: /bind-account/
|
||||
*
|
||||
* 第三方登录未匹配账号时的绑定页面
|
||||
* 用户输入已有账号密码完成OAuth绑定
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
// ============================================
|
||||
// 处理绑定请求(POST)
|
||||
// ============================================
|
||||
$bind_error = '';
|
||||
$bind_verify_url = '';
|
||||
$oauth_data = null;
|
||||
$provider_name = '';
|
||||
$obk = '';
|
||||
|
||||
if (isset($_GET['obk'])) {
|
||||
$obk = sanitize_text_field($_GET['obk']);
|
||||
$oauth_data = \AKSRT\Auth\Service::get_oauth_bind_context($obk);
|
||||
}
|
||||
|
||||
if (! $oauth_data || ! is_array($oauth_data)) {
|
||||
// 无效或已过期的OAuth数据
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$bind_error = __('绑定会话已过期,请重新使用第三方登录', 'aksrt');
|
||||
}
|
||||
} else {
|
||||
$provider_name = \AKSRT\Auth\Service::get_oauth_provider_name($oauth_data['provider'] ?? '');
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['log'], $_POST['pwd']) && empty($bind_error)) {
|
||||
if ($obk === '' && !empty($_POST['obk'])) {
|
||||
$obk = sanitize_text_field($_POST['obk']);
|
||||
}
|
||||
|
||||
if ($oauth_data === null && $obk !== '') {
|
||||
$oauth_data = \AKSRT\Auth\Service::get_oauth_bind_context($obk);
|
||||
}
|
||||
|
||||
$result = \AKSRT\Auth\Service::bind_oauth_account($_POST, $oauth_data);
|
||||
if (empty($result['success'])) {
|
||||
$bind_error = $result['error'] ?? __('绑定失败,请稍后重试', 'aksrt');
|
||||
$bind_verify_url = $result['verify_url'] ?? '';
|
||||
} else {
|
||||
$user = $result['user'];
|
||||
$provider = $result['provider'];
|
||||
wp_safe_redirect(add_query_arg(['tab' => 'settings', 'oauth_bound' => $provider], aksrt_get_user_center_url()));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
remove_action('wp_footer', 'aksrt_render_footer_tabbar', 20);
|
||||
remove_action('wp_footer', 'aksrt_render_float_buttons', 30);
|
||||
add_filter('body_class', static function ($classes) {
|
||||
$classes[] = 'page-template-user-sign';
|
||||
return $classes;
|
||||
});
|
||||
get_header();
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main" tabindex="-1">
|
||||
<div class="auth-shell">
|
||||
<div class="auth-card">
|
||||
|
||||
<?php if (! $oauth_data || ! is_array($oauth_data)) : ?>
|
||||
<!-- 会话过期状态 -->
|
||||
<div class="auth-card__expired">
|
||||
<div class="auth-card__logo sign-logo" aria-hidden="true"><?php if (function_exists('aksrt_get_auth_sign_logo_html')) { echo aksrt_get_auth_sign_logo_html(); } else { echo 'AK'; } // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<h1 class="auth-card__title"><?php bloginfo('name'); ?></h1>
|
||||
<p><?php echo esc_html(__('绑定会话已过期或无效', 'aksrt')); ?></p>
|
||||
<a href="<?php echo esc_url(aksrt_get_login_url()); ?>" class="btn-primary btn-lg auth-card__expired-action">
|
||||
<?php esc_html_e('返回登录', 'aksrt'); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php else : ?>
|
||||
<!-- 正常绑定表单 -->
|
||||
|
||||
<div class="auth-card__logo sign-logo" aria-hidden="true"><?php if (function_exists('aksrt_get_auth_sign_logo_html')) { echo aksrt_get_auth_sign_logo_html(); } else { echo 'AK'; } // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<h1 class="auth-card__title"><?php bloginfo('name'); ?></h1>
|
||||
<p class="auth-card__subtitle">
|
||||
<?php printf(esc_html__('通过 %s 登录,请绑定你的已有账号', 'aksrt'), '<strong>' . esc_html($provider_name) . '</strong>'); ?>
|
||||
</p>
|
||||
|
||||
<?php if (!empty($bind_error)) : ?>
|
||||
<div class="alert alert--error" role="alert">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>
|
||||
<span>
|
||||
<?php echo esc_html($bind_error); ?>
|
||||
<?php if (!empty($bind_verify_url)) : ?>
|
||||
<a href="<?php echo esc_url($bind_verify_url); ?>"><?php esc_html_e('前往验证邮箱', 'aksrt'); ?></a>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form class="auth-form" id="aksrt-bind-form" method="post" action="">
|
||||
<?php wp_nonce_field('aksrt_bind', '_bind_nonce'); ?>
|
||||
<input type="hidden" name="obk" value="<?php echo esc_attr($obk); ?>">
|
||||
<div class="form-field">
|
||||
<label for="bind_user_login"><?php esc_html_e('邮箱 / 用户名', 'aksrt'); ?></label>
|
||||
<div class="input-wrap">
|
||||
<span class="input-icon" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:18px;height:18px;"><rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/></svg></span>
|
||||
<input type="text" name="log" id="bind_user_login" autocomplete="username" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-field form-field--pwd">
|
||||
<label for="bind_user_pass"><?php esc_html_e('密码', 'aksrt'); ?></label>
|
||||
<div class="input-wrap">
|
||||
<span class="input-icon" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:18px;height:18px;"><rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg></span>
|
||||
<input type="password" name="pwd" id="bind_user_pass" autocomplete="current-password" required>
|
||||
<button type="button" class="toggle-pwd" data-target="bind_user_pass" aria-label="<?php esc_attr_e('显示或隐藏密码', 'aksrt'); ?>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:16px;height:16px;"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10 7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg></button>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (function_exists('aksrt_render_captcha')) : ?>
|
||||
<?php aksrt_render_captcha('bind'); ?>
|
||||
<?php endif; ?>
|
||||
<button type="submit" name="wp-submit" class="btn-primary btn-lg" style="width:100%;margin-top:8px;">
|
||||
<?php esc_html_e('绑定并登录', 'aksrt'); ?>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<?php if (class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::registration_enabled() : get_option('users_can_register')) :
|
||||
$register_url = aksrt_get_register_url();
|
||||
$register_url = add_query_arg('obk', sanitize_text_field($_GET['obk']), $register_url);
|
||||
?>
|
||||
<p class="auth-footer-link">
|
||||
<?php esc_html_e('还没有账号?', 'aksrt'); ?>
|
||||
<a href="<?php echo esc_url($register_url); ?>"><?php esc_html_e('注册并绑定账号', 'aksrt'); ?></a>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?><!-- end 正常绑定表单 -->
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php
|
||||
get_footer();
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Template Name: AKSRT - Login
|
||||
* Template Post Type: page
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
require AKSRT_DIR . '/templates/pages/page-sign.php';
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Template Name: AKSRT - Register
|
||||
* Template Post Type: page
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
require AKSRT_DIR . '/templates/pages/page-sign.php';
|
||||
@@ -1,178 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Template Name: AKSRT - Reset Password
|
||||
* Template Post Type: page
|
||||
*
|
||||
* Theme auth route template: /reset-password/
|
||||
*
|
||||
* 统一处理:
|
||||
* 1. 忘记密码(无 token 参数)— 输入邮箱/用户名请求重置
|
||||
* 2. 设置密码(有 token+uid 参数)— 邮件链接进入后设置新密码
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
// ============================================
|
||||
// 检测当前模式:设置密码 or 请求重置
|
||||
// ============================================
|
||||
$context = \AKSRT\Auth\Service::get_reset_context($_GET);
|
||||
$mode = $context['mode'];
|
||||
$errors = [];
|
||||
$success = '';
|
||||
$token = $context['token'];
|
||||
$user_id = $context['user_id'];
|
||||
|
||||
if (!empty($context['error'])) {
|
||||
$errors[] = $context['error'];
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// 处理表单提交
|
||||
// ============================================
|
||||
|
||||
// 模式1:请求重置密码(忘记密码表单提交)
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['aksrt_action']) && $_POST['aksrt_action'] === 'request_reset') {
|
||||
$result = \AKSRT\Auth\Service::request_password_reset($_POST);
|
||||
if (!empty($result['success'])) {
|
||||
$success = $result['message'] ?? __('如果该账号存在,重置邮件已发送到注册邮箱', 'aksrt');
|
||||
} else {
|
||||
$errors[] = $result['error'] ?? __('重置请求失败,请稍后重试', 'aksrt');
|
||||
}
|
||||
}
|
||||
|
||||
// 模式2:设置新密码(从邮件链接进入)
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['aksrt_action']) && $_POST['aksrt_action'] === 'set_password') {
|
||||
$result = \AKSRT\Auth\Service::reset_password_with_token($_POST);
|
||||
if (!empty($result['success'])) {
|
||||
$mode = 'success';
|
||||
$success = $result['message'] ?? __('密码已设置成功!', 'aksrt');
|
||||
} else {
|
||||
$errors[] = $result['error'] ?? __('重置密码失败,请稍后重试', 'aksrt');
|
||||
$mode = $result['mode'] ?? 'invalid';
|
||||
}
|
||||
}
|
||||
|
||||
remove_action('wp_footer', 'aksrt_render_footer_tabbar', 20);
|
||||
remove_action('wp_footer', 'aksrt_render_float_buttons', 30);
|
||||
add_filter('body_class', static function ($classes) {
|
||||
$classes[] = 'page-template-user-sign';
|
||||
return $classes;
|
||||
});
|
||||
get_header();
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main" tabindex="-1">
|
||||
<div class="auth-shell">
|
||||
<div class="auth-card">
|
||||
<div class="auth-card__logo sign-logo" aria-hidden="true"><?php if (function_exists('aksrt_get_auth_sign_logo_html')) { echo aksrt_get_auth_sign_logo_html(); } else { echo 'AK'; } // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<h1 class="auth-card__title"><?php bloginfo('name'); ?></h1>
|
||||
|
||||
<?php if ($mode === 'success') : ?>
|
||||
<!-- 密码设置成功 -->
|
||||
<p class="auth-card__subtitle"><?php esc_html_e('密码设置成功!', 'aksrt'); ?></p>
|
||||
<div class="alert alert--success" role="alert">
|
||||
<span><?php echo esc_html($success); ?></span>
|
||||
</div>
|
||||
<a href="<?php echo esc_url(aksrt_get_login_url()); ?>" class="btn-primary btn-lg" style="width:100%;display:block;text-align:center;text-decoration:none;margin-top:16px;">
|
||||
<?php esc_html_e('立即登录', 'aksrt'); ?>
|
||||
</a>
|
||||
|
||||
<?php elseif ($mode === 'invalid') : ?>
|
||||
<!-- 链接无效或已过期 -->
|
||||
<p class="auth-card__subtitle"><?php esc_html_e('重置链接无效或已过期', 'aksrt'); ?></p>
|
||||
<?php if (!empty($errors)) : ?>
|
||||
<div class="alert alert--error" role="alert">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>
|
||||
<span><?php echo esc_html($errors[0]); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<a href="<?php echo esc_url(aksrt_get_reset_password_url()); ?>" class="btn-primary btn-lg" style="width:100%;display:block;text-align:center;text-decoration:none;margin-top:16px;">
|
||||
<?php esc_html_e('重新申请重置密码', 'aksrt'); ?>
|
||||
</a>
|
||||
|
||||
<?php elseif ($mode === 'reset') : ?>
|
||||
<!-- 设置新密码表单 -->
|
||||
<p class="auth-card__subtitle"><?php esc_html_e('请设置你的新密码', 'aksrt'); ?></p>
|
||||
|
||||
<?php if (!empty($errors)) : ?>
|
||||
<div class="alert alert--error" role="alert">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>
|
||||
<span><?php echo esc_html($errors[0]); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form class="auth-form" id="aksrt-set-password-form" method="post" action="">
|
||||
<?php wp_nonce_field('aksrt_set_password', '_setpw_nonce'); ?>
|
||||
<input type="hidden" name="aksrt_action" value="set_password">
|
||||
<input type="hidden" name="reset_token" value="<?php echo esc_attr($token); ?>">
|
||||
<input type="hidden" name="reset_uid" value="<?php echo esc_attr((string) $user_id); ?>">
|
||||
|
||||
<div class="form-field form-field--pwd">
|
||||
<label for="pass1"><?php esc_html_e('新密码', 'aksrt'); ?></label>
|
||||
<div class="input-wrap">
|
||||
<span class="input-icon" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:18px;height:18px;"><rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg></span>
|
||||
<input type="password" name="pass1" id="pass1" autocomplete="new-password" required minlength="6">
|
||||
<button type="button" class="toggle-pwd" data-target="pass1" aria-label="<?php esc_attr_e('显示或隐藏密码', 'aksrt'); ?>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:16px;height:16px;"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-field form-field--pwd">
|
||||
<label for="pass2"><?php esc_html_e('确认新密码', 'aksrt'); ?></label>
|
||||
<div class="input-wrap">
|
||||
<span class="input-icon" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:18px;height:18px;"><rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg></span>
|
||||
<input type="password" name="pass2" id="pass2" autocomplete="new-password" required minlength="6">
|
||||
<button type="button" class="toggle-pwd" data-target="pass2" aria-label="<?php esc_attr_e('显示或隐藏密码', 'aksrt'); ?>"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:16px;height:16px;"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn-primary btn-lg btn-block"><?php esc_html_e('设置新密码', 'aksrt'); ?></button>
|
||||
</form>
|
||||
|
||||
<?php else : ?>
|
||||
<!-- 请求重置密码表单(忘记密码) -->
|
||||
<p class="auth-card__subtitle"><?php esc_html_e('输入邮箱或用户名,我们将发送重置链接', 'aksrt'); ?></p>
|
||||
|
||||
<?php if (!empty($errors)) : ?>
|
||||
<div class="alert alert--error" role="alert">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>
|
||||
<span><?php echo esc_html($errors[0]); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($success)) : ?>
|
||||
<div class="alert alert--success" role="alert">
|
||||
<span><?php echo esc_html($success); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form class="auth-form" id="aksrt-request-reset-form" method="post" action="">
|
||||
<?php wp_nonce_field('aksrt_reset_password', '_reset_nonce'); ?>
|
||||
<input type="hidden" name="aksrt_action" value="request_reset">
|
||||
|
||||
<div class="form-field">
|
||||
<label for="user_login"><?php esc_html_e('邮箱 / 用户名', 'aksrt'); ?></label>
|
||||
<div class="input-wrap">
|
||||
<span class="input-icon" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:18px;height:18px;"><rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/></svg></span>
|
||||
<input type="text" name="user_login" id="user_login" autocomplete="username" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php aksrt_render_captcha('lostpassword'); ?>
|
||||
|
||||
<button type="submit" class="btn-primary btn-lg btn-block"><?php esc_html_e('发送重置链接', 'aksrt'); ?></button>
|
||||
</form>
|
||||
|
||||
<p class="auth-footer-link">
|
||||
<?php esc_html_e('想起密码了?', 'aksrt'); ?>
|
||||
<a href="<?php echo esc_url(aksrt_get_login_url()); ?>"><?php esc_html_e('返回登录', 'aksrt'); ?></a>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php
|
||||
get_footer();
|
||||
+50
-306
@@ -1,328 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Template Name: AKSRT - 登录/注册
|
||||
* Template Name: AKSRT - 登录注册
|
||||
* Template Post Type: page
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
@session_start();
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$route_tab = function_exists('aksrt_get_auth_tab') ? aksrt_get_auth_tab() : 'login';
|
||||
$requested_tab = isset($_GET['tab']) ? sanitize_text_field(wp_unslash((string) $_GET['tab'])) : '';
|
||||
$tab_aliases = [
|
||||
'login' => 'signin',
|
||||
'signin' => 'signin',
|
||||
'register' => 'signup',
|
||||
'signup' => 'signup',
|
||||
];
|
||||
$tab_source = $requested_tab !== '' ? $requested_tab : $route_tab;
|
||||
$tab = $tab_aliases[$tab_source] ?? 'signin';
|
||||
$redirect_to = !empty($_GET['redirect_to']) ? esc_url_raw(wp_unslash((string) $_GET['redirect_to'])) : home_url();
|
||||
$registration_open = class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::registration_enabled();
|
||||
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'close_signup') && \AKSRT\Settings\Settings::close_signup()) {
|
||||
$registration_open = false;
|
||||
$allowed_tabs = ['signin', 'signup', 'resetpassword', 'bind', 'oauth'];
|
||||
$tab = isset($_GET['tab']) ? sanitize_key(wp_unslash((string) $_GET['tab'])) : 'signin';
|
||||
$tab = in_array($tab, $allowed_tabs, true) ? $tab : 'signin';
|
||||
$wechat = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_weixingzh_settings() : [];
|
||||
if (!isset($_GET['tab']) && !empty($wechat['priority']) && class_exists('\AKSRT\Auth\WeixinGzh') && \AKSRT\Auth\WeixinGzh::is_enabled()) {
|
||||
$tab = 'oauth';
|
||||
}
|
||||
|
||||
$titles = [
|
||||
'signin' => __('用户登录', 'aksrt'),
|
||||
'signup' => __('新用户注册', 'aksrt'),
|
||||
];
|
||||
$page_title = ($titles[$tab] ?? __('登录 / 注册', 'aksrt')) . ' - ' . get_bloginfo('name');
|
||||
|
||||
$interim = isset($_REQUEST['interim-login']);
|
||||
|
||||
if (class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::close_sign() && !is_user_logged_in() && !$interim) {
|
||||
wp_safe_redirect(home_url('/'), 302);
|
||||
exit;
|
||||
$redirect_to = !empty($_GET['redirect_to']) ? esc_url_raw(wp_unslash((string) $_GET['redirect_to'])) : home_url('/');
|
||||
$obk = !empty($_GET['obk']) ? sanitize_text_field(wp_unslash((string) $_GET['obk'])) : '';
|
||||
if (is_user_logged_in() && $tab !== 'bind' && $tab !== 'oauth') {
|
||||
wp_safe_redirect($redirect_to);
|
||||
exit;
|
||||
}
|
||||
|
||||
$close_signin = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::close_signin() : false;
|
||||
if ($close_signin && $tab === 'signin') {
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
if (class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::close_sign() && !$interim) {
|
||||
wp_safe_redirect(home_url('/'));
|
||||
exit;
|
||||
}
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
if ($user_id) {
|
||||
if ($interim && is_super_admin()) {
|
||||
echo '<!DOCTYPE HTML><html><body class="login interim-login-success"><div style="padding:60px 0;text-align:center;color:#1a88fd;">' . esc_html__('登录成功', 'aksrt') . '</div></body></html>';
|
||||
exit;
|
||||
}
|
||||
wp_safe_redirect($redirect_to);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($tab === 'signup' && !$registration_open) {
|
||||
$tab = 'signin';
|
||||
if ($tab === 'signup' && class_exists('\AKSRT\Settings\Settings') && !\AKSRT\Settings\Settings::registration_enabled()) {
|
||||
$tab = 'signin';
|
||||
}
|
||||
|
||||
remove_action('wp_footer', 'aksrt_render_footer_tabbar', 20);
|
||||
remove_action('wp_footer', 'aksrt_render_float_buttons', 30);
|
||||
|
||||
$background_html = '';
|
||||
$sign_ui = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::sign_page_ui() : [];
|
||||
$card_position = $sign_ui['card_position'] ?? 'center';
|
||||
$sign_show_logo = $sign_ui['show_logo'] ?? true;
|
||||
$sign_show_header = !empty($sign_ui['show_header']);
|
||||
$sign_theme_mode = $sign_ui['theme_mode'] ?? 'default';
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$bg_ids = $sign_ui['background'] ?? [];
|
||||
if (is_array($bg_ids) && !empty($bg_ids)) {
|
||||
$bg_url = wp_get_attachment_url((int) $bg_ids[array_rand($bg_ids)]);
|
||||
if ($bg_url) {
|
||||
$background_html = '<div class="sign-bg" style="background-image:url(' . esc_url($bg_url) . ');"></div>';
|
||||
}
|
||||
} elseif (is_string($bg_ids) && $bg_ids !== '') {
|
||||
$ids = array_filter(array_map('absint', explode(',', $bg_ids)));
|
||||
if (!empty($ids)) {
|
||||
$bg_url = wp_get_attachment_url($ids[array_rand($ids)]);
|
||||
if ($bg_url) {
|
||||
$background_html = '<div class="sign-bg" style="background-image:url(' . esc_url($bg_url) . ');"></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$ui = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::sign_page_ui() : [];
|
||||
$images = $ui['background'] ?? [];
|
||||
if (is_string($images)) {
|
||||
$images = array_filter(array_map('absint', explode(',', $images)));
|
||||
}
|
||||
|
||||
$login_error = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['log'], $_POST['pwd']) && $tab === 'signin') {
|
||||
if (class_exists('\AKSRT\Auth\Service')) {
|
||||
$result = \AKSRT\Auth\Service::login_user($_POST, false);
|
||||
if (empty($result['success'])) {
|
||||
$login_error = $result['error'] ?? __('登录失败', 'aksrt');
|
||||
} else {
|
||||
wp_safe_redirect($result['redirect'] ?? home_url('/'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$register_error = '';
|
||||
$register_success = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['user_login'], $_POST['user_email']) && $tab === 'signup') {
|
||||
if (class_exists('\AKSRT\Auth\Service')) {
|
||||
$result = \AKSRT\Auth\Service::register_user($_POST, ['oauth_bind_data' => null, 'obk' => '']);
|
||||
if (!empty($result['success'])) {
|
||||
$ref_notice = trim((string) ($result['notice'] ?? ''));
|
||||
if (!empty($result['verification_required'])) {
|
||||
$register_success = sprintf(
|
||||
'%s <a href="%s">%s</a>',
|
||||
esc_html($result['message'] ?? __('注册成功,请完成邮箱验证。', 'aksrt')),
|
||||
esc_url($result['verify_url'] ?? ''),
|
||||
esc_html__('前往验证', 'aksrt')
|
||||
);
|
||||
} else {
|
||||
$register_success = sprintf(
|
||||
__('注册成功,请前往<a href="%s">登录页</a>继续。', 'aksrt'),
|
||||
esc_url(aksrt_get_login_url())
|
||||
);
|
||||
}
|
||||
if ($ref_notice !== '') {
|
||||
$register_success .= ' ' . esc_html($ref_notice);
|
||||
}
|
||||
} else {
|
||||
$register_error = $result['error'] ?? __('注册失败', 'aksrt');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ref_prefill = '';
|
||||
if (!empty($_COOKIE['aksrt_referral'])) {
|
||||
$ref_prefill = sanitize_key(wp_unslash($_COOKIE['aksrt_referral']));
|
||||
} elseif (!empty($_GET['ref'])) {
|
||||
$ref_prefill = sanitize_key(wp_unslash($_GET['ref']));
|
||||
}
|
||||
|
||||
$agreement = function_exists('aksrt_get_auth_agreement_view')
|
||||
? aksrt_get_auth_agreement_view()
|
||||
: ['enabled' => true, 'required' => true, 'label_html' => esc_html__('我已阅读并同意用户协议', 'aksrt'), 'field_name' => 'agree_terms'];
|
||||
|
||||
$sign_css_uri = get_template_directory_uri() . '/assets/css/routes/sign.css';
|
||||
$sign_css_ver = file_exists(get_template_directory() . '/assets/css/routes/sign.css')
|
||||
? (string) filemtime(get_template_directory() . '/assets/css/routes/sign.css')
|
||||
: AKSRT_VERSION;
|
||||
$background_url = is_array($images) && $images ? (string) wp_get_attachment_url((int) $images[array_rand($images)]) : '';
|
||||
$theme_mode = (string) ($ui['theme_mode'] ?? 'no');
|
||||
$position = (string) ($ui['card_position'] ?? 'right');
|
||||
$aksrt_auth_context = [
|
||||
'surface' => 'page',
|
||||
'tab' => $tab,
|
||||
'show_logo' => !empty($ui['show_logo']),
|
||||
'redirect_to' => $redirect_to,
|
||||
'obk' => $obk,
|
||||
];
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo esc_attr(str_replace('_', '-', get_bloginfo('language'))); ?>">
|
||||
<!doctype html>
|
||||
<html <?php language_attributes(); ?>>
|
||||
<head>
|
||||
<meta charset="<?php bloginfo('charset'); ?>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<title><?php echo esc_html($page_title); ?></title>
|
||||
<?php wp_head(); ?>
|
||||
<link rel="stylesheet" href="<?php echo esc_url($sign_css_uri); ?>?ver=<?php echo esc_attr($sign_css_ver); ?>">
|
||||
<meta charset="<?php bloginfo('charset'); ?>">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<title><?php echo esc_html__('登录 / 注册', 'aksrt') . ' - ' . esc_html(get_bloginfo('name')); ?></title>
|
||||
<?php wp_head(); ?>
|
||||
</head>
|
||||
<body <?php body_class('page-template-user-sign' . ($sign_theme_mode !== 'default' ? ' sign-theme-' . esc_attr($sign_theme_mode) : '')); ?>>
|
||||
<?php echo $background_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
|
||||
<?php if ($sign_show_header && !$interim) : ?>
|
||||
<div class="sign-topbar">
|
||||
<a href="<?php echo esc_url(home_url('/')); ?>"><?php echo esc_html(get_bloginfo('name')); ?></a>
|
||||
<a href="<?php echo esc_url(home_url('/')); ?>"><?php esc_html_e('返回首页', 'aksrt'); ?></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<main class="sign-page">
|
||||
<div class="sign-card sign-card--<?php echo esc_attr($card_position); ?>">
|
||||
<?php if ($sign_show_logo) : ?>
|
||||
<div class="sign-logo">
|
||||
<?php echo function_exists('aksrt_get_auth_sign_logo_html') ? aksrt_get_auth_sign_logo_html() : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="sign-tabs">
|
||||
<button type="button" class="sign-tab<?php echo $tab === 'signin' ? ' is-active' : ''; ?>" data-sign-tab="signin"><?php esc_html_e('登录', 'aksrt'); ?></button>
|
||||
<?php if ($registration_open) : ?>
|
||||
<button type="button" class="sign-tab<?php echo $tab === 'signup' ? ' is-active' : ''; ?>" data-sign-tab="signup"><?php esc_html_e('注册', 'aksrt'); ?></button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="sign-panel<?php echo $tab === 'signin' ? ' is-active' : ''; ?>" data-sign-panel="signin">
|
||||
<?php if ($login_error) : ?><div class="sign-error"><?php echo esc_html($login_error); ?></div><?php endif; ?>
|
||||
<?php if ($close_signin) : ?>
|
||||
<div class="sign-notice">
|
||||
<?php esc_html_e('当前站点仅支持第三方账号登录,请使用下方社交登录方式。', 'aksrt'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<form class="sign-form" id="sign-login-form" method="post" action="">
|
||||
<?php wp_nonce_field('aksrt_login', '_login_nonce'); ?>
|
||||
<div class="form-field">
|
||||
<label for="sign-user-login"><?php esc_html_e('邮箱 / 用户名', 'aksrt'); ?></label>
|
||||
<div class="input-wrap"><input type="text" name="log" id="sign-user-login" autocomplete="username" required placeholder="<?php esc_attr_e('请输入邮箱或用户名', 'aksrt'); ?>"></div>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label for="sign-user-pass"><?php esc_html_e('密码', 'aksrt'); ?></label>
|
||||
<div class="input-wrap">
|
||||
<input type="password" name="pwd" id="sign-user-pass" autocomplete="current-password" required>
|
||||
<button type="button" class="toggle-pwd" data-target="sign-user-pass"><i class="fa fas fa-eye"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row-between">
|
||||
<label><input type="checkbox" name="rememberme" value="forever"> <?php esc_html_e('记住我', 'aksrt'); ?></label>
|
||||
<a href="<?php echo esc_url(aksrt_get_reset_password_url()); ?>"><?php esc_html_e('忘记密码?', 'aksrt'); ?></a>
|
||||
</div>
|
||||
<?php if (function_exists('aksrt_render_captcha')) aksrt_render_captcha('login'); ?>
|
||||
<input type="hidden" name="redirect_to" value="<?php echo esc_url($redirect_to); ?>">
|
||||
<button type="submit" class="btn-submit"><?php esc_html_e('登录', 'aksrt'); ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
<?php if (class_exists('\AKSRT\Auth\OAuth')) : ?>
|
||||
<?php $social = \AKSRT\Auth\OAuth::get_instance()->render_social_buttons(); ?>
|
||||
<?php if ($social) : ?>
|
||||
<div class="sign-oauth">
|
||||
<div class="sign-oauth__divider"><span><?php esc_html_e('其他登录方式', 'aksrt'); ?></span></div>
|
||||
<?php echo $social; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($registration_open) : ?>
|
||||
<div class="sign-footer"><?php esc_html_e('还没有账号?', 'aksrt'); ?> <a href="#" data-sign-switch="signup"><?php esc_html_e('立即注册', 'aksrt'); ?></a></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($registration_open) : ?>
|
||||
<div class="sign-panel<?php echo $tab === 'signup' ? ' is-active' : ''; ?>" data-sign-panel="signup">
|
||||
<?php if ($register_error) : ?><div class="sign-error"><?php echo esc_html($register_error); ?></div><?php endif; ?>
|
||||
<?php if ($register_success) : ?><div class="sign-success"><?php echo wp_kses($register_success, ['a' => ['href' => []]]); ?></div><?php endif; ?>
|
||||
<form class="sign-form" id="sign-register-form" method="post" action="" novalidate>
|
||||
<?php wp_nonce_field('aksrt_register', '_register_nonce'); ?>
|
||||
<div class="form-field">
|
||||
<label for="sign-reg-login"><?php esc_html_e('用户名', 'aksrt'); ?></label>
|
||||
<div class="input-wrap"><input type="text" name="user_login" id="sign-reg-login" autocomplete="username" required placeholder="<?php esc_attr_e('请输入用户名', 'aksrt'); ?>"></div>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label for="sign-reg-email"><?php esc_html_e('邮箱', 'aksrt'); ?></label>
|
||||
<div class="input-wrap"><input type="email" name="user_email" id="sign-reg-email" autocomplete="email" required placeholder="<?php esc_attr_e('请输入邮箱', 'aksrt'); ?>"></div>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label for="sign-reg-pass"><?php esc_html_e('登录密码', 'aksrt'); ?></label>
|
||||
<div class="input-wrap">
|
||||
<input type="password" name="user_pass" id="sign-reg-pass" autocomplete="new-password" required minlength="6">
|
||||
<button type="button" class="toggle-pwd" data-target="sign-reg-pass"><i class="fa fas fa-eye"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label for="sign-reg-pass2"><?php esc_html_e('确认密码', 'aksrt'); ?></label>
|
||||
<div class="input-wrap">
|
||||
<input type="password" name="user_pass_confirm" id="sign-reg-pass2" autocomplete="new-password" required minlength="6">
|
||||
<button type="button" class="toggle-pwd" data-target="sign-reg-pass2"><i class="fa fas fa-eye"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$ref_cfg = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_referral_registration_settings() : null;
|
||||
if ($ref_cfg && !empty($ref_cfg['enabled']) && ($ref_cfg['register_field'] ?? 'hidden') !== 'hidden') {
|
||||
$mode = (string) $ref_cfg['register_field'];
|
||||
$ref_hint = $mode === 'required'
|
||||
? (string) ($ref_cfg['required_desc'] ?? '')
|
||||
: (string) ($ref_cfg['open_desc'] ?? '');
|
||||
?>
|
||||
<div class="form-field">
|
||||
<label for="sign-ref"><?php esc_html_e('推广码', 'aksrt'); ?><?php echo $mode === 'optional' ? ' <small style="color:var(--muted-color);">(' . esc_html__('选填', 'aksrt') . ')</small>' : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></label>
|
||||
<div class="input-wrap"><input type="text" name="ref" id="sign-ref" maxlength="12" autocomplete="off" value="<?php echo esc_attr($ref_prefill); ?>" <?php echo $mode === 'required' ? 'required' : ''; ?>></div>
|
||||
<?php if ($ref_hint !== '') : ?>
|
||||
<p class="sign-hint"><?php echo wp_kses_post($ref_hint); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if (!empty($agreement['enabled'])) : ?>
|
||||
<label class="sign-terms">
|
||||
<input type="checkbox" name="<?php echo esc_attr($agreement['field_name']); ?>" value="1" <?php echo !empty($agreement['required']) ? 'required' : ''; ?>>
|
||||
<span><?php echo $agreement['label_html']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php if (class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::registration_requires_email_verification()) : ?>
|
||||
<p class="sign-hint"><?php esc_html_e('注册后需要完成邮箱验证。', 'aksrt'); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if (function_exists('aksrt_render_captcha')) aksrt_render_captcha('register'); ?>
|
||||
<button type="submit" class="btn-submit"><?php esc_html_e('注册', 'aksrt'); ?></button>
|
||||
</form>
|
||||
<div class="sign-footer"><?php esc_html_e('已有账号?', 'aksrt'); ?> <a href="#" data-sign-switch="signin"><?php esc_html_e('立即登录', 'aksrt'); ?></a></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
(function(){
|
||||
document.querySelectorAll('[data-sign-tab]').forEach(function(tab){
|
||||
tab.addEventListener('click',function(){
|
||||
var target=this.getAttribute('data-sign-tab');
|
||||
this.parentElement.querySelectorAll('.sign-tab').forEach(function(t){t.classList.remove('is-active');});
|
||||
this.classList.add('is-active');
|
||||
var card=this.closest('.sign-card');
|
||||
card.querySelectorAll('.sign-panel[data-sign-panel]').forEach(function(p){p.classList.remove('is-active');});
|
||||
var panel=card.querySelector('[data-sign-panel="'+target+'"]');
|
||||
if(panel)panel.classList.add('is-active');
|
||||
});
|
||||
});
|
||||
document.querySelectorAll('[data-sign-switch]').forEach(function(link){
|
||||
link.addEventListener('click',function(e){
|
||||
e.preventDefault();
|
||||
var target=this.getAttribute('data-sign-switch');
|
||||
var btn=document.querySelector('[data-sign-tab="'+target+'"]');
|
||||
if(btn)btn.click();
|
||||
});
|
||||
});
|
||||
document.querySelectorAll('.toggle-pwd').forEach(function(btn){
|
||||
btn.addEventListener('click',function(){
|
||||
var input=document.getElementById(this.getAttribute('data-target'));
|
||||
if(!input)return;
|
||||
var isPw=input.type==='password';
|
||||
input.type=isPw?'text':'password';
|
||||
this.querySelector('i').className=isPw?'fa fas fa-eye-slash':'fa fas fa-eye';
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php if (!$interim) : ?>
|
||||
<div class="sign-footer-bar">
|
||||
<?php
|
||||
$footer_text = $sign_ui['footer'] ?? '';
|
||||
echo $footer_text ? wp_kses_post($footer_text) : '© ' . date('Y') . ' ' . esc_html(get_bloginfo('name'));
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php wp_footer(); ?>
|
||||
<body <?php body_class('page-template-user-sign ' . ($theme_mode !== 'no' ? $theme_mode : '')); ?>>
|
||||
<?php wp_body_open(); ?>
|
||||
<div class="sign-page-background"<?php echo $background_url !== '' ? ' style="background-image:url(\'' . esc_url($background_url) . '\')"' : ''; ?>></div>
|
||||
<?php if (!empty($ui['show_header']) && !$interim) : ?><header class="sign-topbar"><a href="<?php echo esc_url(home_url('/')); ?>"><?php echo esc_html(get_bloginfo('name')); ?></a><a href="<?php echo esc_url(home_url('/')); ?>"><?php esc_html_e('返回首页', 'aksrt'); ?></a></header><?php endif; ?>
|
||||
<main class="sign-page sign-card-position-<?php echo esc_attr($position); ?>">
|
||||
<div class="sign-page-card">
|
||||
<?php require get_template_directory() . '/templates/parts/auth-content.php'; ?>
|
||||
</div>
|
||||
</main>
|
||||
<?php if (!$interim) : ?><footer class="sign-page-footer"><?php echo !empty($ui['footer']) ? wp_kses_post((string) $ui['footer']) : '© ' . esc_html(wp_date('Y')) . ' ' . esc_html(get_bloginfo('name')); ?></footer><?php endif; ?>
|
||||
<?php wp_footer(); ?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,155 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Template Name: AKSRT - Verify Email
|
||||
* Template Post Type: page
|
||||
*
|
||||
* Theme auth route template: /verify-email/
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
$verify_error = '';
|
||||
$verify_success = '';
|
||||
$redirect_url = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_POST['verify_email_resend'])) {
|
||||
$result = \AKSRT\Auth\Service::resend_email_verification($_POST);
|
||||
if (!empty($result['success'])) {
|
||||
$verify_success = $result['message'] ?? __('验证邮件已重新发送,请注意查收。', 'aksrt');
|
||||
} else {
|
||||
$verify_error = $result['error'] ?? __('验证邮件发送失败,请稍后重试。', 'aksrt');
|
||||
}
|
||||
} elseif (isset($_POST['verify_email_submit'])) {
|
||||
$result = \AKSRT\Auth\Service::verify_email_code_submission($_POST);
|
||||
if (!empty($result['success'])) {
|
||||
$verify_success = $result['message'] ?? __('邮箱验证成功,即将进入你的账号。', 'aksrt');
|
||||
$redirect_url = $result['redirect'] ?? '';
|
||||
} else {
|
||||
$verify_error = $result['error'] ?? __('邮箱验证码错误或已过期。', 'aksrt');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$verify_context = \AKSRT\Auth\Service::get_email_verification_context($_GET);
|
||||
if ($verify_error === '' && !empty($verify_context['error'])) {
|
||||
$verify_error = $verify_context['error'];
|
||||
}
|
||||
if ($verify_success === '' && !empty($verify_context['message'])) {
|
||||
$verify_success = $verify_context['message'];
|
||||
}
|
||||
if ($redirect_url === '' && !empty($verify_context['redirect'])) {
|
||||
$redirect_url = $verify_context['redirect'];
|
||||
}
|
||||
|
||||
$verify_user = $verify_context['user'] ?? null;
|
||||
$verify_uid = (int) ($verify_context['uid'] ?? 0);
|
||||
$verify_email = (string) ($verify_context['email'] ?? '');
|
||||
$verify_mode = (string) ($verify_context['mode'] ?? 'invalid');
|
||||
$verify_method= (string) ($verify_context['method'] ?? '');
|
||||
$verify_vk = (string) ($verify_context['access_key'] ?? '');
|
||||
|
||||
remove_action('wp_footer', 'aksrt_render_footer_tabbar', 20);
|
||||
remove_action('wp_footer', 'aksrt_render_float_buttons', 30);
|
||||
add_filter('body_class', static function ($classes) {
|
||||
$classes[] = 'page-template-user-sign';
|
||||
return $classes;
|
||||
});
|
||||
get_header();
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main sign-page" tabindex="-1">
|
||||
<div class="auth-shell">
|
||||
<div class="auth-card sign-card sign-card--center">
|
||||
<div class="auth-card__logo sign-logo" aria-hidden="true"><?php if (function_exists('aksrt_get_auth_sign_logo_html')) { echo aksrt_get_auth_sign_logo_html(); } else { echo 'AK'; } // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<h1 class="auth-card__title"><?php bloginfo('name'); ?></h1>
|
||||
|
||||
<?php if ($verify_mode === 'completed' || $verify_mode === 'verified') : ?>
|
||||
<p class="auth-card__subtitle"><?php esc_html_e('邮箱验证成功', 'aksrt'); ?></p>
|
||||
<?php elseif ($verify_mode === 'code') : ?>
|
||||
<p class="auth-card__subtitle"><?php esc_html_e('请输入邮箱验证码完成验证', 'aksrt'); ?></p>
|
||||
<?php elseif ($verify_mode === 'pending') : ?>
|
||||
<p class="auth-card__subtitle"><?php esc_html_e('验证邮件已经发出,请点击邮箱中的链接完成验证', 'aksrt'); ?></p>
|
||||
<?php else : ?>
|
||||
<p class="auth-card__subtitle"><?php esc_html_e('邮箱验证状态异常,请重新检查链接或重新发送验证邮件', 'aksrt'); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($verify_error !== '') : ?>
|
||||
<div class="alert alert--error" role="alert">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>
|
||||
<span><?php echo esc_html($verify_error); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($verify_success !== '') : ?>
|
||||
<div class="alert alert--success" role="alert">
|
||||
<span><?php echo esc_html($verify_success); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (($verify_mode === 'completed' || $verify_mode === 'verified') && $redirect_url !== '') : ?>
|
||||
<p class="auth-footer-link">
|
||||
<a href="<?php echo esc_url($redirect_url); ?>"><?php esc_html_e('立即进入账号', 'aksrt'); ?></a>
|
||||
</p>
|
||||
<script>
|
||||
setTimeout(function(){ window.location.href = <?php echo wp_json_encode($redirect_url); ?>; }, 1800);
|
||||
</script>
|
||||
<?php elseif ($verify_mode === 'code') : ?>
|
||||
<form class="auth-form" method="post" action="">
|
||||
<?php wp_nonce_field('aksrt_verify_email', '_verify_email_nonce'); ?>
|
||||
<input type="hidden" name="verify_uid" value="<?php echo esc_attr((string) $verify_uid); ?>">
|
||||
<input type="hidden" name="vk" value="<?php echo esc_attr($verify_vk); ?>">
|
||||
<div class="form-field">
|
||||
<label for="verify_email_code"><?php esc_html_e('邮箱验证码', 'aksrt'); ?></label>
|
||||
<div class="input-wrap">
|
||||
<span class="input-icon" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:18px;height:18px;"><rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/></svg></span>
|
||||
<input type="text" name="email_code" id="verify_email_code" inputmode="numeric" maxlength="6" pattern="[0-9]*" autocomplete="one-time-code" required>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($verify_email !== '') : ?>
|
||||
<p class="auth-card__subtitle" style="margin-top:-8px;"><?php echo esc_html(sprintf(__('验证码已发送到 %s', 'aksrt'), $verify_email)); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if (function_exists('aksrt_render_captcha')) : ?>
|
||||
<?php aksrt_render_captcha('verify_email'); ?>
|
||||
<?php endif; ?>
|
||||
<button type="submit" name="verify_email_submit" class="btn-primary btn-lg btn-block"><?php esc_html_e('验证并登录', 'aksrt'); ?></button>
|
||||
</form>
|
||||
<form method="post" action="" style="margin-top:12px;">
|
||||
<?php wp_nonce_field('aksrt_verify_email', '_verify_email_nonce'); ?>
|
||||
<input type="hidden" name="verify_uid" value="<?php echo esc_attr((string) $verify_uid); ?>">
|
||||
<input type="hidden" name="vk" value="<?php echo esc_attr($verify_vk); ?>">
|
||||
<?php if (function_exists('aksrt_render_captcha')) : ?>
|
||||
<?php aksrt_render_captcha('verify_email'); ?>
|
||||
<?php endif; ?>
|
||||
<button type="submit" name="verify_email_resend" class="btn-primary btn-lg" style="width:100%;background:transparent;color:var(--color-primary);border:1px solid var(--color-primary);"><?php esc_html_e('重新发送验证码', 'aksrt'); ?></button>
|
||||
</form>
|
||||
<?php elseif ($verify_mode === 'pending' && $verify_uid > 0 && $verify_vk !== '') : ?>
|
||||
<?php
|
||||
// method 缺失(历史账号 / meta 被外部清理)→ 回退到设置默认值
|
||||
$resend_method = in_array($verify_method, ['link', 'code'], true)
|
||||
? $verify_method
|
||||
: (class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::registration_verification_method() : 'link');
|
||||
?>
|
||||
<?php if ($verify_email !== '') : ?>
|
||||
<p class="auth-card__subtitle"><?php echo esc_html(sprintf(__('当前待验证邮箱:%s', 'aksrt'), $verify_email)); ?></p>
|
||||
<?php endif; ?>
|
||||
<form method="post" action="">
|
||||
<?php wp_nonce_field('aksrt_verify_email', '_verify_email_nonce'); ?>
|
||||
<input type="hidden" name="verify_uid" value="<?php echo esc_attr((string) $verify_uid); ?>">
|
||||
<input type="hidden" name="vk" value="<?php echo esc_attr($verify_vk); ?>">
|
||||
<?php if (function_exists('aksrt_render_captcha')) : ?>
|
||||
<?php aksrt_render_captcha('verify_email'); ?>
|
||||
<?php endif; ?>
|
||||
<button type="submit" name="verify_email_resend" class="btn-primary btn-lg" style="width:100%;"><?php echo esc_html($resend_method === 'code' ? __('重新发送验证码', 'aksrt') : __('重新发送验证邮件', 'aksrt')); ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<p class="auth-footer-link">
|
||||
<a href="<?php echo esc_url(aksrt_get_login_url()); ?>"><?php esc_html_e('返回登录', 'aksrt'); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php
|
||||
get_footer();
|
||||
Reference in new issue
Block a user