登录注册体系的源码级硬切换
This commit is contained in:
1 parent
73fcd4ed72
commit
af52f9e94d
72 files changed
+1666
-6576
No files matched your search
@@ -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
@@ -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>
|
||||
Reference in new issue
Block a user