feat(auth): 登录注册找回绑定前台 1:1 壳层/文案/协议

抽出 sign.css,统一全页登录/注册与找回/绑定视觉;中文文案与用户协议契约对齐 Auth_Service;弹层字段与 logo 同步。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-12 11:14:10 +08:00
co-authored by Claude Fable 5
parent badc76936d
commit 8d1b0dacf6
10 changed files with 511 additions and 114 deletions
+50 -71
View File
@@ -1,4 +1,4 @@
<?php
<?php
/**
* Template Name: AKSRT - 登录/注册
* Template Post Type: page
@@ -20,25 +20,25 @@ $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') && AKSRT_Settings::registration_enabled();
if (class_exists('AKSRT_Settings') && method_exists('AKSRT_Settings', 'close_signup') && AKSRT_Settings::close_signup()) {
$registration_open = false;
}
$titles = [
'signin' => __('用户登录', 'aksrt'),
'signup' => __('用户注册', 'aksrt'),
'signup' => __('新用户注册', 'aksrt'),
];
$page_title = ($titles[$tab] ?? __('登录 / 注册', 'aksrt')) . ' - ' . get_bloginfo('name');
$interim = isset($_REQUEST['interim-login']);
// 搂4.1 Defense-in-depth: redirect out when close_sign is active (backup of auth router gate)
if (class_exists('AKSRT_Settings') && AKSRT_Settings::close_sign() && !is_user_logged_in() && !$interim) {
wp_safe_redirect(home_url('/'), 302);
exit;
}
// §4.1 close_signin: password login disabled — force signin tab to show social-only message
$close_signin = class_exists('AKSRT_Settings') ? AKSRT_Settings::close_signin() : false;
if ($close_signin && $tab === 'signin') {
// Don't allow password form submission
$_SERVER['REQUEST_METHOD'] = 'GET';
}
@@ -63,7 +63,7 @@ $background_html = '';
$sign_ui = class_exists('AKSRT_Settings') ? AKSRT_Settings::sign_page_ui() : [];
$card_position = $sign_ui['card_position'] ?? 'center';
$sign_show_logo = $sign_ui['show_logo'] ?? true;
$sign_show_header = $sign_ui['show_header'] ?? true;
$sign_show_header = !empty($sign_ui['show_header']);
$sign_theme_mode = $sign_ui['theme_mode'] ?? 'default';
if (class_exists('AKSRT_Settings')) {
$bg_ids = $sign_ui['background'] ?? [];
@@ -73,7 +73,6 @@ if (class_exists('AKSRT_Settings')) {
$background_html = '<div class="sign-bg" style="background-image:url(' . esc_url($bg_url) . ');"></div>';
}
} elseif (is_string($bg_ids) && $bg_ids !== '') {
// BC: comma-separated string from old storage
$ids = array_filter(array_map('absint', explode(',', $bg_ids)));
if (!empty($ids)) {
$bg_url = wp_get_attachment_url($ids[array_rand($ids)]);
@@ -106,13 +105,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['user_login'], $_POST[
if (!empty($result['verification_required'])) {
$register_success = sprintf(
'%s <a href="%s">%s</a>',
esc_html($result['message'] ?? __('Registration successful. Please complete email verification.', 'aksrt')),
esc_html($result['message'] ?? __('注册成功,请完成邮箱验证。', 'aksrt')),
esc_url($result['verify_url'] ?? ''),
esc_html__('前往验证', 'aksrt')
);
} else {
$register_success = sprintf(
__('Registration successful. Please continue on the <a href="%s">login page</a>.', 'aksrt'),
__('注册成功,请前往<a href="%s">登录页</a>继续。', 'aksrt'),
esc_url(aksrt_get_login_url())
);
}
@@ -128,6 +127,15 @@ if (!empty($_GET['invite'])) {
} elseif (!empty($_COOKIE['aksrt_invite'])) {
$invite_prefill = sanitize_key(wp_unslash($_COOKIE['aksrt_invite']));
}
$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;
?>
<!DOCTYPE html>
<html lang="<?php echo esc_attr(str_replace('_', '-', get_bloginfo('language'))); ?>">
@@ -137,81 +145,45 @@ if (!empty($_GET['invite'])) {
<meta name="robots" content="noindex, nofollow">
<title><?php echo esc_html($page_title); ?></title>
<?php wp_head(); ?>
<style>
.sign-page{min-height:100vh;display:flex;align-items:center;justify-content:center;position:relative;padding:70px 16px 40px}
.sign-bg{position:fixed;inset:0;background-repeat:no-repeat;background-size:cover;background-position:center;z-index:0}
.sign-card{position:relative;z-index:1;width:100%;max-width:420px;background:var(--main-bg-color,#fff);border-radius:var(--main-radius,8px);box-shadow:0 0 10px var(--main-shadow,rgba(116,116,116,0.08));padding:30px 35px}
.sign-card--left{margin-right:auto}
.sign-card--right{margin-left:auto}
.sign-card--center{margin:0 auto}
.sign-logo{text-align:center;margin-bottom:20px}
.sign-logo img{height:36px}
.sign-logo__text{display:inline-flex;align-items:center;justify-content:center;width:48px;height:48px;border-radius:12px;background:var(--focus-color,#f04494);color:#fff;font-size:18px;font-weight:700;text-decoration:none}
.sign-tabs{display:flex;border-bottom:2px solid var(--main-border-color,rgba(50,50,50,0.06));margin-bottom:20px}
.sign-tab{flex:1;padding:10px 0;border:none;background:none;font-size:15px;cursor:pointer;color:var(--muted-color,#777);border-bottom:2px solid transparent;margin-bottom:-2px;transition:all .2s;text-align:center;font-weight:500}
.sign-tab.is-active{color:var(--focus-color,#f04494);border-bottom-color:var(--focus-color,#f04494);font-weight:600}
.sign-tab:hover{color:var(--focus-color,#f04494)}
.sign-panel{display:none}
.sign-panel.is-active{display:block}
.sign-error{background:rgba(239,68,68,0.08);border:1px solid rgba(239,68,68,0.2);border-radius:var(--main-radius,8px);padding:10px 14px;font-size:13px;color:#ef4444;margin-bottom:16px}
.sign-success{background:rgba(16,185,129,0.08);border:1px solid rgba(16,185,129,0.2);border-radius:var(--main-radius,8px);padding:10px 14px;font-size:13px;color:#10b981;margin-bottom:16px}
.sign-form{display:flex;flex-direction:column;gap:16px}
.sign-form .form-field{display:flex;flex-direction:column;gap:6px}
.sign-form label{font-size:14px;font-weight:500;color:var(--main-color,#4e5358)}
.sign-form .input-wrap{position:relative}
.sign-form .input-wrap input{width:100%;height:44px;padding:0 14px;border:1px solid transparent;background:var(--body-bg-color,#f5f6f7);border-radius:var(--main-radius,8px);font-size:14px;color:var(--key-color,#333);transition:border-color .15s}
.sign-form .input-wrap input:focus{outline:none;border-color:var(--focus-color,#f04494);box-shadow:0 0 2px 3px var(--focus-shadow-color,rgba(253,83,161,0.4))}
.sign-form .toggle-pwd{position:absolute;right:10px;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--muted-2-color,#999);padding:4px}
.sign-form .form-row-between{display:flex;align-items:center;justify-content:space-between;font-size:13px}
.sign-form .form-row-between a{color:var(--focus-color,#f04494)}
.sign-form .form-row-between label{display:flex;align-items:center;gap:6px;cursor:pointer;font-size:13px;color:var(--muted-color,#777)}
.sign-form .btn-submit{width:100%;height:44px;border:none;border-radius:var(--main-radius,8px);background:var(--focus-color,#f04494);color:#fff;font-size:15px;font-weight:600;cursor:pointer;transition:opacity .15s}
.sign-form .btn-submit:hover{opacity:.85}
.sign-form .btn-submit:disabled{opacity:.5;cursor:not-allowed}
.sign-hint{margin:0;font-size:13px;color:var(--muted-color,#777)}
.sign-terms{display:flex;align-items:flex-start;gap:8px;font-size:13px;cursor:pointer;color:var(--muted-color,#777)}
.sign-footer{text-align:center;margin-top:20px;font-size:14px;color:var(--muted-color,#777)}
.sign-footer a{color:var(--focus-color,#f04494)}
.sign-footer-bar{position:fixed;bottom:0;left:0;right:0;text-align:center;padding:10px;font-size:12px;color:var(--muted-2-color,#999);z-index:1}
@media(max-width:480px){.sign-card{padding:24px 20px}}
</style>
<link rel="stylesheet" href="<?php echo esc_url($sign_css_uri); ?>?ver=<?php echo esc_attr($sign_css_ver); ?>">
</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 $logo_url = class_exists('AKSRT_Settings') ? AKSRT_Settings::user_logo_url() : ''; ?>
<?php if ($logo_url) : ?>
<a href="<?php echo esc_url(home_url('/')); ?>"><img src="<?php echo esc_url($logo_url); ?>" alt="<?php echo esc_attr(get_bloginfo('name')); ?>"></a>
<?php else : ?>
<a href="<?php echo esc_url(home_url('/')); ?>" class="sign-logo__text"><?php echo esc_html(mb_substr(get_bloginfo('name'), 0, 2)); ?></a>
<?php endif; ?>
<?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; ?>
<?php if ($sign_show_header) : ?>
<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>
<?php endif; ?>
<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" style="padding:16px;text-align:center;color:var(--muted-2-color,#666);">
<?php esc_html_e('This site currently supports third-party account sign-in only. Please use one of the social login buttons below.', 'aksrt'); ?>
<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('Email / Username', 'aksrt'); ?></label>
<div class="input-wrap"><input type="text" name="log" id="sign-user-login" autocomplete="username" required placeholder="<?php esc_attr_e('Please enter your email or username', 'aksrt'); ?>"></div>
<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>
@@ -221,20 +193,25 @@ if (!empty($_GET['invite'])) {
</div>
</div>
<div class="form-row-between">
<label><input type="checkbox" name="rememberme" value="forever"> <?php esc_html_e('Remember me', 'aksrt'); ?></label>
<a href="<?php echo esc_url(aksrt_get_reset_password_url()); ?>"><?php esc_html_e('Forgot password?', 'aksrt'); ?></a>
<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; // close_signin gate ?>
<?php endif; ?>
<?php if (class_exists('AKSRT_OAuth')) : ?>
<?php $social = AKSRT_OAuth::get_instance()->render_social_buttons(); ?>
<?php if ($social) echo '<div style="margin-top:20px;">' . $social . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?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('Don\'t have an account yet?', 'aksrt'); ?> <a href="#" data-sign-switch="signup"><?php esc_html_e('Register now', 'aksrt'); ?></a></div>
<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>
@@ -245,12 +222,12 @@ if (!empty($_GET['invite'])) {
<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('Username', 'aksrt'); ?></label>
<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('Email Address', 'aksrt'); ?></label>
<div class="input-wrap"><input type="email" name="user_email" id="sign-reg-email" autocomplete="email" required placeholder="<?php esc_attr_e('Please enter your email', 'aksrt'); ?>"></div>
<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>
@@ -282,17 +259,19 @@ if (!empty($_GET['invite'])) {
<?php endif; ?>
</div>
<?php } ?>
<?php if (!empty($agreement['enabled'])) : ?>
<label class="sign-terms">
<input type="checkbox" name="agree_terms" value="1" required>
<span><?php esc_html_e('I agree to the Terms of Service', 'aksrt'); ?></span>
<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') && AKSRT_Settings::registration_requires_email_verification()) : ?>
<p class="sign-hint"><?php esc_html_e('Email verification is required after registration.', 'aksrt'); ?></p>
<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('Already have an account?', 'aksrt'); ?> <a href="#" data-sign-switch="signin"><?php esc_html_e('Sign in now', 'aksrt'); ?></a></div>
<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>