登录注册体系的源码级硬切换

This commit is contained in:
kate522 committed 2026-08-23 20:30:01 +08:00
1 parent 73fcd4ed72
commit af52f9e94d
72 files changed
+1666 -6576

No files matched your search

-145
View File
@@ -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();
-11
View File
@@ -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';
-11
View File
@@ -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';
-178
View File
@@ -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
View File
@@ -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) : '&copy; ' . 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']) : '&copy; ' . esc_html(wp_date('Y')) . ' ' . esc_html(get_bloginfo('name')); ?></footer><?php endif; ?>
<?php wp_footer(); ?>
</body>
</html>
-155
View File
@@ -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();
+146
View File
@@ -0,0 +1,146 @@
<?php
/**
* Shared authentication renderer for the modal and /sign/ page.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$aksrt_auth_context = isset($aksrt_auth_context) && is_array($aksrt_auth_context) ? $aksrt_auth_context : [];
$auth_tab = sanitize_key((string) ($aksrt_auth_context['tab'] ?? 'signin'));
$allowed_tabs = ['signin', 'signup', 'resetpassword', 'bind', 'oauth'];
$auth_tab = in_array($auth_tab, $allowed_tabs, true) ? $auth_tab : 'signin';
$is_modal = ($aksrt_auth_context['surface'] ?? '') === 'modal';
$settings = class_exists('\AKSRT\Settings\Settings') ? '\AKSRT\Settings\Settings' : null;
$obk = sanitize_text_field((string) ($aksrt_auth_context['obk'] ?? ''));
$oauth_bind_data = $obk !== '' && class_exists('\AKSRT\Auth\Service') ? \AKSRT\Auth\Service::get_oauth_bind_context($obk) : null;
$is_oauth_bind = is_array($oauth_bind_data);
$registration_open = ($settings ? $settings::registration_enabled() : (bool) get_option('users_can_register')) || $is_oauth_bind;
$close_signin = $settings ? $settings::close_signin() : false;
$signin_phone = $settings ? $settings::signin_phone_enabled() : false;
$passwordless = $settings ? $settings::passwordless_login_enabled() : false;
$passwordless_type = $settings ? $settings::passwordless_login_type() : 'email';
$passwordless_mode = $settings ? $settings::nopas_active_mode() : 'pas';
$signup_verify = $settings ? $settings::signup_verification_enabled() : false;
$signup_type = $settings ? $settings::signup_verification_type() : 'email';
$signup_type = $signup_verify ? $signup_type : 'email';
$reset_type = $settings ? $settings::reset_password_verification_type() : 'email';
$omit_confirm = $signup_verify && ($settings ? $settings::signup_omit_password_confirmation() : false);
$agreement = function_exists('aksrt_get_auth_agreement_view') ? aksrt_get_auth_agreement_view() : ['enabled' => false, 'required' => false, 'label_html' => '', 'field_name' => 'agree_terms'];
$referral = $settings ? $settings::get_referral_registration_settings() : ['enabled' => false, 'register_field' => 'hidden'];
$ref_mode = !empty($referral['enabled']) ? (string) ($referral['register_field'] ?? 'hidden') : 'hidden';
$ref_hint = $ref_mode === 'required' ? (string) ($referral['required_desc'] ?? '') : (string) ($referral['open_desc'] ?? '');
$ref_value = !empty($_GET['ref']) ? sanitize_key(wp_unslash((string) $_GET['ref'])) : (!empty($_COOKIE['aksrt_referral']) ? sanitize_key(wp_unslash((string) $_COOKIE['aksrt_referral'])) : '');
$oauth_providers = class_exists('\AKSRT\Auth\OAuth') ? \AKSRT\Auth\OAuth::get_instance()->get_auth_providers_data() : [];
$wechat_qr = false;
foreach ($oauth_providers as $provider) {
if (($provider['name'] ?? '') === 'weixingzh') {
$wechat_qr = true;
break;
}
}
$show_logo = !empty($aksrt_auth_context['show_logo']);
$oauth_large = $settings ? (bool) $settings::get_value('oauth_button_lg', false) : false;
$redirect_to = esc_url_raw((string) ($aksrt_auth_context['redirect_to'] ?? home_url('/')));
$unique = $is_modal ? 'modal' : 'page';
$oauth_user_data = $is_oauth_bind && !empty($oauth_bind_data['user_data']) && is_array($oauth_bind_data['user_data']) ? $oauth_bind_data['user_data'] : [];
$oauth_name = sanitize_user((string) ($oauth_user_data['name'] ?? $oauth_user_data['nickname'] ?? $oauth_user_data['login'] ?? ''), true);
$oauth_email = sanitize_email((string) ($oauth_user_data['email'] ?? ''));
$oauth_provider_name = $is_oauth_bind ? \AKSRT\Auth\Service::get_oauth_provider_name((string) ($oauth_bind_data['provider'] ?? '')) : '';
?>
<div class="sign aksrt-auth<?php echo $oauth_large ? ' oauth-button-lg' : ''; ?>" data-aksrt-auth data-surface="<?php echo esc_attr($unique); ?>" data-initial-tab="<?php echo esc_attr($auth_tab); ?>" data-passwordless-mode="<?php echo esc_attr($passwordless_mode); ?>">
<?php if ($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; ?>
<section class="sign-panel" data-auth-panel="signin" <?php echo $auth_tab !== 'signin' ? 'hidden' : ''; ?>>
<div class="sign-header"><h2><?php esc_html_e('登录', 'aksrt'); ?></h2><?php if ($registration_open) : ?><span><?php esc_html_e('没有账号?', 'aksrt'); ?> <button type="button" data-auth-tab="signup"><?php esc_html_e('立即注册', 'aksrt'); ?></button></span><?php endif; ?></div>
<div class="sign-message" data-auth-message hidden></div>
<?php if (!$close_signin) : ?>
<form class="sign-form" data-auth-form="login">
<div class="floating-input"><input name="target" id="<?php echo esc_attr($unique); ?>-login-target" autocomplete="username" required><label for="<?php echo esc_attr($unique); ?>-login-target"><?php echo ($passwordless || $signin_phone) ? esc_html__('邮箱 / 手机号 / 用户名', 'aksrt') : esc_html__('邮箱 / 用户名', 'aksrt'); ?></label></div>
<div data-auth-password-fields <?php echo $passwordless && $passwordless_mode !== 'pas' ? 'hidden' : ''; ?>>
<div class="floating-input has-action"><input type="password" name="password" id="<?php echo esc_attr($unique); ?>-login-password" autocomplete="current-password"><label for="<?php echo esc_attr($unique); ?>-login-password"><?php esc_html_e('密码', 'aksrt'); ?></label><button type="button" class="password-show" data-password-show aria-label="<?php esc_attr_e('显示密码', 'aksrt'); ?>"><i class="fa fas fa-eye"></i></button></div>
</div>
<?php if ($passwordless) : ?>
<div data-auth-code-fields <?php echo $passwordless_mode === 'pas' ? 'hidden' : ''; ?>>
<div class="floating-input has-action"><input name="code" inputmode="numeric" maxlength="6" id="<?php echo esc_attr($unique); ?>-login-code"><label for="<?php echo esc_attr($unique); ?>-login-code"><?php esc_html_e('验证码', 'aksrt'); ?></label><button type="button" class="send-code" data-send-code="login"><?php esc_html_e('发送验证码', 'aksrt'); ?></button></div>
<input type="hidden" name="channel" value="<?php echo esc_attr($passwordless_type === 'phone' ? 'phone' : ''); ?>">
</div>
<?php endif; ?>
<div class="sign-options"><label><input type="checkbox" name="rememberme" value="1"> <?php esc_html_e('记住登录', 'aksrt'); ?></label><button type="button" data-auth-tab="resetpassword"><?php esc_html_e('忘记密码?', 'aksrt'); ?></button></div>
<?php if (function_exists('aksrt_render_captcha')) { aksrt_render_captcha('login'); } ?>
<input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>">
<button type="submit" class="sign-submit jb-blue"><span><?php esc_html_e('登录', 'aksrt'); ?></span><i class="fa fas fa-spinner fa-spin" hidden></i></button>
<?php if ($passwordless && $passwordless_mode !== 'only_nopas') : ?><button type="button" class="sign-mode-switch" data-login-mode><?php echo $passwordless_mode === 'pas' ? esc_html__('使用验证码登录', 'aksrt') : esc_html__('使用账号密码登录', 'aksrt'); ?></button><?php endif; ?>
</form>
<?php else : ?><div class="sign-notice"><?php esc_html_e('当前已关闭账号密码登录,请使用第三方登录。', 'aksrt'); ?></div><?php endif; ?>
</section>
<?php if ($registration_open) : ?>
<section class="sign-panel" data-auth-panel="signup" <?php echo $auth_tab !== 'signup' ? 'hidden' : ''; ?>>
<div class="sign-header"><h2><?php echo $is_oauth_bind ? esc_html__('注册并绑定', 'aksrt') : esc_html__('注册', 'aksrt'); ?></h2><span><?php esc_html_e('已有账号?', 'aksrt'); ?> <button type="button" data-auth-tab="<?php echo $is_oauth_bind ? 'bind' : 'signin'; ?>"><?php esc_html_e('立即登录', 'aksrt'); ?></button></span></div>
<div class="sign-message" data-auth-message hidden></div>
<form class="sign-form" data-auth-form="register">
<div class="floating-input"><input name="user_login" value="<?php echo esc_attr($oauth_name); ?>" id="<?php echo esc_attr($unique); ?>-register-name" autocomplete="username" required><label for="<?php echo esc_attr($unique); ?>-register-name"><?php esc_html_e('用户名', 'aksrt'); ?></label></div>
<div class="floating-input"><input name="target" value="<?php echo esc_attr($oauth_email); ?>" id="<?php echo esc_attr($unique); ?>-register-target" autocomplete="<?php echo $signup_type === 'phone' ? 'tel' : 'email'; ?>" required><label for="<?php echo esc_attr($unique); ?>-register-target"><?php echo $signup_type === 'phone' ? esc_html__('手机号', 'aksrt') : ($signup_type === 'email_phone' ? esc_html__('邮箱 / 手机号', 'aksrt') : esc_html__('邮箱', 'aksrt')); ?></label></div>
<?php if ($signup_verify) : ?><div class="floating-input has-action"><input name="code" inputmode="numeric" maxlength="6" id="<?php echo esc_attr($unique); ?>-register-code" required><label for="<?php echo esc_attr($unique); ?>-register-code"><?php esc_html_e('验证码', 'aksrt'); ?></label><button type="button" class="send-code" data-send-code="register"><?php esc_html_e('发送验证码', 'aksrt'); ?></button></div><?php endif; ?>
<div class="floating-input has-action"><input type="password" name="password" id="<?php echo esc_attr($unique); ?>-register-password" autocomplete="new-password" minlength="6" required><label for="<?php echo esc_attr($unique); ?>-register-password"><?php esc_html_e('密码', 'aksrt'); ?></label><button type="button" class="password-show" data-password-show><i class="fa fas fa-eye"></i></button></div>
<?php if (!$omit_confirm) : ?><div class="floating-input has-action"><input type="password" name="password_confirm" id="<?php echo esc_attr($unique); ?>-register-confirm" autocomplete="new-password" minlength="6" required><label for="<?php echo esc_attr($unique); ?>-register-confirm"><?php esc_html_e('重复密码', 'aksrt'); ?></label><button type="button" class="password-show" data-password-show><i class="fa fas fa-eye"></i></button></div><?php endif; ?>
<?php if ($ref_mode !== 'hidden') : ?><div class="floating-input"><input name="ref" value="<?php echo esc_attr($ref_value); ?>" id="<?php echo esc_attr($unique); ?>-register-ref" <?php echo $ref_mode === 'required' ? 'required' : ''; ?>><label for="<?php echo esc_attr($unique); ?>-register-ref"><?php echo $ref_mode === 'required' ? esc_html__('推广码', 'aksrt') : esc_html__('推广码(选填)', 'aksrt'); ?></label></div><?php if ($ref_hint !== '') : ?><div class="sign-hint"><?php echo wp_kses_post($ref_hint); ?></div><?php endif; ?><?php endif; ?>
<?php if (!empty($agreement['enabled']) && !empty($agreement['required'])) : ?><label class="sign-agreement"><input type="checkbox" name="agree_terms" value="1" required><span><?php echo $agreement['label_html']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span></label><?php elseif (!empty($agreement['enabled'])) : ?><div class="sign-agreement sign-agreement-implicit"><?php esc_html_e('注册即表示', 'aksrt'); ?><?php echo $agreement['label_html']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div><?php endif; ?>
<?php if (function_exists('aksrt_render_captcha')) { aksrt_render_captcha('register'); } ?>
<input type="hidden" name="channel" value="<?php echo esc_attr($signup_type === 'phone' ? 'phone' : ''); ?>">
<input type="hidden" name="user_email" value="">
<?php if ($is_oauth_bind) : ?><input type="hidden" name="obk" value="<?php echo esc_attr($obk); ?>"><?php endif; ?>
<button type="submit" class="sign-submit jb-green"><span><?php esc_html_e('注册', 'aksrt'); ?></span><i class="fa fas fa-spinner fa-spin" hidden></i></button>
</form>
</section>
<?php endif; ?>
<section class="sign-panel" data-auth-panel="resetpassword" <?php echo $auth_tab !== 'resetpassword' ? 'hidden' : ''; ?>>
<div class="sign-header"><h2><?php esc_html_e('找回密码', 'aksrt'); ?></h2><span><button type="button" data-auth-tab="signin"><?php esc_html_e('返回登录', 'aksrt'); ?></button></span></div>
<div class="sign-message" data-auth-message hidden></div>
<form class="sign-form" data-auth-form="reset-password">
<div class="floating-input"><input name="target" id="<?php echo esc_attr($unique); ?>-reset-target" required><label for="<?php echo esc_attr($unique); ?>-reset-target"><?php echo $reset_type === 'phone' ? esc_html__('手机号', 'aksrt') : ($reset_type === 'email_phone' ? esc_html__('邮箱 / 手机号', 'aksrt') : esc_html__('邮箱', 'aksrt')); ?></label></div>
<div class="floating-input has-action"><input name="code" inputmode="numeric" maxlength="6" id="<?php echo esc_attr($unique); ?>-reset-code" required><label for="<?php echo esc_attr($unique); ?>-reset-code"><?php esc_html_e('验证码', 'aksrt'); ?></label><button type="button" class="send-code" data-send-code="resetpassword"><?php esc_html_e('发送验证码', 'aksrt'); ?></button></div>
<div class="floating-input has-action"><input type="password" name="password" id="<?php echo esc_attr($unique); ?>-reset-password" minlength="6" required><label for="<?php echo esc_attr($unique); ?>-reset-password"><?php esc_html_e('新密码', 'aksrt'); ?></label><button type="button" class="password-show" data-password-show><i class="fa fas fa-eye"></i></button></div>
<div class="floating-input has-action"><input type="password" name="password_confirm" id="<?php echo esc_attr($unique); ?>-reset-confirm" minlength="6" required><label for="<?php echo esc_attr($unique); ?>-reset-confirm"><?php esc_html_e('重复新密码', 'aksrt'); ?></label><button type="button" class="password-show" data-password-show><i class="fa fas fa-eye"></i></button></div>
<?php if (function_exists('aksrt_render_captcha')) { aksrt_render_captcha('lostpassword'); } ?>
<input type="hidden" name="channel" value="<?php echo esc_attr($reset_type === 'phone' ? 'phone' : ''); ?>">
<button type="submit" class="sign-submit jb-blue"><span><?php esc_html_e('重置密码', 'aksrt'); ?></span><i class="fa fas fa-spinner fa-spin" hidden></i></button>
</form>
</section>
<section class="sign-panel" data-auth-panel="oauth" <?php echo $auth_tab !== 'oauth' ? 'hidden' : ''; ?>>
<div class="sign-header"><h2><?php esc_html_e('社交登录', 'aksrt'); ?></h2><span><button type="button" data-auth-tab="signin"><?php esc_html_e('返回登录', 'aksrt'); ?></button></span></div>
<div class="sign-message" data-auth-message hidden></div>
<?php if ($wechat_qr) : ?><div class="auth-qrcode" data-auth-qrcode><i class="fa fab fa-weixin"></i><span><?php esc_html_e('获取二维码中…', 'aksrt'); ?></span></div><?php endif; ?>
</section>
<section class="sign-panel" data-auth-panel="bind" <?php echo $auth_tab !== 'bind' ? 'hidden' : ''; ?>>
<div class="sign-header"><h2><?php esc_html_e('绑定账号', 'aksrt'); ?></h2><?php if ($is_oauth_bind && $registration_open) : ?><span><?php esc_html_e('没有账号?', 'aksrt'); ?> <button type="button" data-auth-tab="signup"><?php esc_html_e('立即注册', 'aksrt'); ?></button></span><?php endif; ?></div>
<div class="sign-message" data-auth-message hidden></div>
<?php if ($is_oauth_bind) : ?>
<div class="sign-notice"><?php printf(esc_html__('通过 %s 登录,请绑定已有账号。', 'aksrt'), esc_html($oauth_provider_name)); ?></div>
<form class="sign-form" data-auth-form="login">
<div class="floating-input"><input name="target" id="<?php echo esc_attr($unique); ?>-bind-target" autocomplete="username" required><label for="<?php echo esc_attr($unique); ?>-bind-target"><?php echo $signin_phone ? esc_html__('邮箱 / 手机号 / 用户名', 'aksrt') : esc_html__('邮箱 / 用户名', 'aksrt'); ?></label></div>
<div class="floating-input has-action"><input type="password" name="password" id="<?php echo esc_attr($unique); ?>-bind-password" autocomplete="current-password" required><label for="<?php echo esc_attr($unique); ?>-bind-password"><?php esc_html_e('密码', 'aksrt'); ?></label><button type="button" class="password-show" data-password-show><i class="fa fas fa-eye"></i></button></div>
<?php if (function_exists('aksrt_render_captcha')) { aksrt_render_captcha('bind'); } ?>
<input type="hidden" name="obk" value="<?php echo esc_attr($obk); ?>">
<input type="hidden" name="rememberme" value="1">
<input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>">
<button type="submit" class="sign-submit jb-blue"><span><?php esc_html_e('登录并绑定', 'aksrt'); ?></span><i class="fa fas fa-spinner fa-spin" hidden></i></button>
</form>
<?php else : ?><div class="sign-notice"><?php esc_html_e('绑定会话已过期,请重新使用第三方登录。', 'aksrt'); ?></div><?php endif; ?>
</section>
<?php if (!empty($oauth_providers) && !$is_oauth_bind) : ?>
<div class="social-login"><span><?php esc_html_e('其他登录方式', 'aksrt'); ?></span><div class="social-login-buttons">
<?php foreach ($oauth_providers as $provider) : ?><a class="social-login-item <?php echo esc_attr((string) ($provider['name'] ?? '')); ?>" href="<?php echo esc_url((string) ($provider['url'] ?? '#')); ?>" title="<?php echo esc_attr((string) ($provider['label'] ?? '')); ?>"><?php echo $provider['icon'] ?? ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><?php if ($oauth_large) : ?><span><?php printf(esc_html__('%s登录', 'aksrt'), esc_html((string) ($provider['label'] ?? ''))); ?></span><?php endif; ?></a><?php endforeach; ?>
<?php if ($wechat_qr) : ?><button type="button" class="social-login-item weixingzh" data-auth-tab="oauth" title="<?php esc_attr_e('微信扫码登录', 'aksrt'); ?>"><i class="fa fab fa-weixin"></i><?php if ($oauth_large) : ?><span><?php esc_html_e('微信登录', 'aksrt'); ?></span><?php endif; ?></button><?php endif; ?>
</div></div>
<?php if (!empty($agreement['enabled'])) : ?><div class="sign-agreement sign-agreement-implicit"><?php esc_html_e('使用社交账号登录即表示', 'aksrt'); ?><?php echo $agreement['label_html']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div><?php endif; ?>
<?php endif; ?>
</div>
+28 -254
View File
@@ -1,268 +1,42 @@
<?php
/**
* Modal auth dialog.
* Shared authentication modal shell.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
if (is_user_logged_in()) {
return;
if (is_user_logged_in() || (class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::close_sign())) {
return;
}
$oauth_providers = [];
if (class_exists('\AKSRT\Auth\OAuth')) {
$oauth_providers = \AKSRT\Auth\OAuth::get_instance()->get_auth_providers_data();
$modal_ui = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::modal_ui() : [];
$images = $modal_ui['background'] ?? [];
if (is_string($images)) {
$images = array_filter(array_map('absint', explode(',', $images)));
}
$registration_open = true;
$email_verification = false;
$close_signin = false;
$ref_field_mode = 'hidden';
$ref_field_hint = '';
$ref_prefill = '';
$show_qrcode_tab = false;
if (class_exists('\AKSRT\Settings\Settings')) {
$registration_open = \AKSRT\Settings\Settings::registration_enabled();
if (method_exists('\AKSRT\Settings\Settings', 'close_signup') && \AKSRT\Settings\Settings::close_signup()) {
$registration_open = false;
}
$email_verification = \AKSRT\Settings\Settings::registration_requires_email_verification();
$close_signin = \AKSRT\Settings\Settings::close_signin();
$ref_cfg = \AKSRT\Settings\Settings::get_referral_registration_settings();
$ref_field_mode = !empty($ref_cfg['enabled']) ? (string) ($ref_cfg['register_field'] ?? 'hidden') : 'hidden';
$ref_field_hint = $ref_field_mode === 'required'
? (string) ($ref_cfg['required_desc'] ?? '')
: (string) ($ref_cfg['open_desc'] ?? '');
$image_url = '';
if (is_array($images) && $images) {
$image_url = (string) wp_get_attachment_url((int) $images[array_rand($images)]);
}
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']));
}
foreach ($oauth_providers as $provider) {
if (($provider['name'] ?? '') === 'weixingzh') {
$show_qrcode_tab = true;
break;
}
}
$site_name = get_bloginfo('name');
$reset_url = function_exists('aksrt_get_reset_password_url') ? aksrt_get_reset_password_url() : wp_lostpassword_url();
$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'];
$logo_url = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::user_logo_url() : '';
$auto = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::sign_modal_auto() : ['enabled' => false, 'waiting' => 5, 'expires' => 1];
$wechat = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_weixingzh_settings() : [];
$initial_tab = !empty($wechat['priority']) && class_exists('\AKSRT\Auth\WeixinGzh') && \AKSRT\Auth\WeixinGzh::is_enabled() ? 'oauth' : 'signin';
$aksrt_auth_context = [
'surface' => 'modal',
'tab' => $initial_tab,
'show_logo' => !empty($modal_ui['show_logo']),
'redirect_to' => home_url('/'),
];
?>
<div class="aksrt-modal-auth" id="aksrt-modal-auth" aria-hidden="true" role="dialog" aria-modal="true" aria-label="<?php esc_attr_e('登录', 'aksrt'); ?>">
<div class="aksrt-modal-auth__overlay"></div>
<div class="aksrt-modal-auth__card">
<button type="button" class="aksrt-modal-auth__close" aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>">
<i class="fa fas fa-times"></i>
</button>
<div class="aksrt-modal-auth__header modal-colorful-header">
<?php if ($logo_url) : ?>
<div class="aksrt-modal-auth__logo aksrt-modal-auth__logo--image"><img src="<?php echo esc_url($logo_url); ?>" alt=""></div>
<?php else : ?>
<div class="aksrt-modal-auth__logo"><?php echo esc_html(mb_substr($site_name, 0, 2)); ?></div>
<?php endif; ?>
<h2 class="aksrt-modal-auth__title"><?php echo esc_html($site_name); ?></h2>
</div>
<div class="aksrt-modal-auth__tabs" role="tablist">
<button type="button" class="aksrt-modal-auth__tab is-active" data-tab="login" role="tab" aria-selected="true">
<?php esc_html_e('登录', 'aksrt'); ?>
</button>
<?php if ($registration_open) : ?>
<button type="button" class="aksrt-modal-auth__tab" data-tab="register" role="tab" aria-selected="false">
<?php esc_html_e('注册', 'aksrt'); ?>
</button>
<?php endif; ?>
<?php if ($show_qrcode_tab) : ?>
<button type="button" class="aksrt-modal-auth__tab" data-tab="qrcode" role="tab" aria-selected="false">
<?php esc_html_e('扫码登录', 'aksrt'); ?>
</button>
<?php endif; ?>
</div>
<div class="aksrt-modal-auth__panel is-active" data-panel="login">
<?php if ($close_signin) : ?>
<div class="aksrt-modal-auth__error is-success" id="aksrt-modal-login-error">
<?php esc_html_e('当前已关闭账密登录,请使用下方第三方登录方式。', 'aksrt'); ?>
</div>
<?php else : ?>
<form class="aksrt-modal-auth__form" id="aksrt-modal-login-form">
<div class="aksrt-modal-auth__error" id="aksrt-modal-login-error" hidden></div>
<?php wp_nonce_field('aksrt_login', '_login_nonce'); ?>
<div class="aksrt-modal-auth__field">
<label for="modal-login-user"><?php esc_html_e('邮箱 / 用户名', 'aksrt'); ?></label>
<input type="text" id="modal-login-user" name="log" autocomplete="username" required placeholder="<?php esc_attr_e('请输入邮箱或用户名', 'aksrt'); ?>">
</div>
<div class="aksrt-modal-auth__field">
<label for="modal-login-pass"><?php esc_html_e('密码', 'aksrt'); ?></label>
<div class="aksrt-modal-auth__pass-wrap">
<input type="password" id="modal-login-pass" name="pwd" autocomplete="current-password" required placeholder="<?php esc_attr_e('请输入密码', 'aksrt'); ?>">
<button type="button" class="aksrt-modal-auth__pass-toggle" aria-label="<?php esc_attr_e('显示或隐藏密码', 'aksrt'); ?>">
<i class="fa fas fa-eye"></i>
</button>
</div>
</div>
<?php if (function_exists('aksrt_render_captcha')) : ?>
<?php aksrt_render_captcha('login'); ?>
<?php endif; ?>
<div class="aksrt-modal-auth__actions">
<a href="<?php echo esc_url($reset_url); ?>" class="aksrt-modal-auth__link"><?php esc_html_e('忘记密码?', 'aksrt'); ?></a>
</div>
<button type="submit" class="aksrt-modal-auth__submit">
<span><?php esc_html_e('登录', 'aksrt'); ?></span>
<i class="fa fas fa-spinner fa-spin" hidden></i>
</button>
</form>
<?php endif; ?>
</div>
<?php if ($registration_open) : ?>
<div class="aksrt-modal-auth__panel" data-panel="register">
<form class="aksrt-modal-auth__form" id="aksrt-modal-register-form">
<div class="aksrt-modal-auth__error" id="aksrt-modal-register-error" hidden></div>
<?php wp_nonce_field('aksrt_register', '_register_nonce'); ?>
<div class="aksrt-modal-auth__field">
<label for="modal-reg-user"><?php esc_html_e('用户名', 'aksrt'); ?></label>
<input type="text" id="modal-reg-user" name="user_login" autocomplete="username" required placeholder="<?php esc_attr_e('请输入用户名', 'aksrt'); ?>">
</div>
<div class="aksrt-modal-auth__field">
<label for="modal-reg-email"><?php esc_html_e('邮箱', 'aksrt'); ?></label>
<input type="email" id="modal-reg-email" name="user_email" autocomplete="email" required placeholder="<?php esc_attr_e('请输入邮箱', 'aksrt'); ?>">
</div>
<div class="aksrt-modal-auth__field">
<label for="modal-reg-pass"><?php esc_html_e('密码', 'aksrt'); ?></label>
<div class="aksrt-modal-auth__pass-wrap">
<input type="password" id="modal-reg-pass" name="user_pass" autocomplete="new-password" required minlength="6" placeholder="<?php esc_attr_e('至少 6 位字符', 'aksrt'); ?>">
<button type="button" class="aksrt-modal-auth__pass-toggle" aria-label="<?php esc_attr_e('显示或隐藏密码', 'aksrt'); ?>">
<i class="fa fas fa-eye"></i>
</button>
</div>
</div>
<div class="aksrt-modal-auth__field">
<label for="modal-reg-pass-confirm"><?php esc_html_e('确认密码', 'aksrt'); ?></label>
<div class="aksrt-modal-auth__pass-wrap">
<input type="password" id="modal-reg-pass-confirm" name="user_pass_confirm" autocomplete="new-password" required minlength="6" placeholder="<?php esc_attr_e('请再次输入密码', 'aksrt'); ?>">
<button type="button" class="aksrt-modal-auth__pass-toggle" aria-label="<?php esc_attr_e('显示或隐藏密码', 'aksrt'); ?>">
<i class="fa fas fa-eye"></i>
</button>
</div>
</div>
<?php if ($ref_field_mode !== 'hidden') : ?>
<div class="aksrt-modal-auth__field">
<label for="modal-reg-ref">
<?php esc_html_e('推广码', 'aksrt'); ?>
<?php if ($ref_field_mode === 'optional') : ?>
<small><?php esc_html_e('(选填)', 'aksrt'); ?></small>
<?php endif; ?>
</label>
<input type="text" id="modal-reg-ref" name="ref" maxlength="12" value="<?php echo esc_attr($ref_prefill); ?>" <?php echo $ref_field_mode === 'required' ? 'required' : ''; ?> placeholder="<?php esc_attr_e('请输入推广码', 'aksrt'); ?>">
<?php if ($ref_field_hint !== '') : ?>
<p class="aksrt-modal-auth__hint"><?php echo wp_kses_post($ref_field_hint); ?></p>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if (!empty($agreement['enabled'])) : ?>
<label class="aksrt-modal-auth__checkbox aksrt-modal-auth__agreement">
<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 ($email_verification) : ?>
<p class="aksrt-modal-auth__hint"><?php esc_html_e('注册后需要完成邮箱验证。', 'aksrt'); ?></p>
<?php endif; ?>
<?php if (function_exists('aksrt_render_captcha')) : ?>
<?php aksrt_render_captcha('register'); ?>
<?php endif; ?>
<button type="submit" class="aksrt-modal-auth__submit">
<span><?php esc_html_e('注册', 'aksrt'); ?></span>
<i class="fa fas fa-spinner fa-spin" hidden></i>
</button>
</form>
</div>
<?php endif; ?>
<?php if ($show_qrcode_tab) : ?>
<div class="aksrt-modal-auth__panel" data-panel="qrcode">
<div class="aksrt-modal-auth__form">
<div class="aksrt-modal-auth__error" id="aksrt-modal-qrcode-error" hidden></div>
<div class="aksrt-modal-auth__qr-code"></div>
<p class="aksrt-modal-auth__hint"><?php esc_html_e('请使用微信扫码,在手机上完成登录。', 'aksrt'); ?></p>
</div>
</div>
<?php endif; ?>
<?php if (!empty($oauth_providers)) : ?>
<div class="aksrt-modal-auth__divider">
<span><?php esc_html_e('其他登录方式', 'aksrt'); ?></span>
</div>
<div class="aksrt-modal-auth__oauth">
<?php foreach ($oauth_providers as $provider) :
$provider_name = (string) ($provider['name'] ?? '');
$label = $provider['label'] ?? $provider_name;
$url = $provider['url'] ?? '#';
$icon = $provider['icon'] ?? '';
?>
<a
href="<?php echo esc_url($url); ?>"
class="aksrt-modal-auth__oauth-btn social-login-item <?php echo esc_attr($provider_name); ?>"
data-provider="<?php echo esc_attr($provider_name); ?>"
title="<?php echo esc_attr($label); ?>"
>
<?php echo $icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="aksrt-modal-auth__footer">
<span class="aksrt-modal-auth__footer-text" data-for="login">
<?php if ($registration_open) : ?>
<?php esc_html_e('还没有账号?', 'aksrt'); ?>
<button type="button" class="aksrt-modal-auth__switch" data-switch="register"><?php esc_html_e('立即注册', 'aksrt'); ?></button>
<?php elseif ($show_qrcode_tab) : ?>
<?php esc_html_e('使用扫码登录?', 'aksrt'); ?>
<button type="button" class="aksrt-modal-auth__switch" data-switch="qrcode"><?php esc_html_e('打开扫码登录', 'aksrt'); ?></button>
<?php endif; ?>
</span>
<?php if ($registration_open) : ?>
<span class="aksrt-modal-auth__footer-text" data-for="register" hidden>
<?php esc_html_e('已有账号?', 'aksrt'); ?>
<button type="button" class="aksrt-modal-auth__switch" data-switch="login"><?php esc_html_e('立即登录', 'aksrt'); ?></button>
</span>
<?php endif; ?>
<?php if ($show_qrcode_tab) : ?>
<span class="aksrt-modal-auth__footer-text" data-for="qrcode" hidden>
<?php esc_html_e('改用密码登录?', 'aksrt'); ?>
<button type="button" class="aksrt-modal-auth__switch" data-switch="login"><?php esc_html_e('返回登录', 'aksrt'); ?></button>
</span>
<?php endif; ?>
</div>
</div>
<div id="u_sign" class="aksrt-auth-modal<?php echo $image_url !== '' ? ' has-sign-img' : ''; ?>" aria-hidden="true" role="dialog" aria-modal="true" data-auth-modal data-auto="<?php echo !empty($auto['enabled']) ? '1' : '0'; ?>" data-auto-wait="<?php echo esc_attr((string) $auto['waiting']); ?>" data-auto-expires="<?php echo esc_attr((string) $auto['expires']); ?>">
<div class="auth-modal-backdrop" data-auth-close></div>
<div class="modal-dialog">
<div class="modal-content">
<button type="button" class="auth-modal-close" data-auth-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fa fas fa-times"></i></button>
<?php if ($image_url !== '') : ?><div class="sign-img" style="background-image:url('<?php echo esc_url($image_url); ?>')"></div><?php endif; ?>
<?php require get_template_directory() . '/templates/parts/auth-content.php'; ?>
</div>
</div>
</div>