Проект разделен на два репозитория
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
phoneTitle=Вход в HAN
|
||||
authBrandSubtitle=Персональный консультант мигранта
|
||||
phoneWelcome=Добро пожаловать
|
||||
phoneIntro=Введите номер телефона — отправим код подтверждения
|
||||
phoneLabel=Номер телефона
|
||||
phoneCountry=Россия · Код страны +7
|
||||
phoneLegalPrefix=Нажимая «Получить код», вы соглашаетесь с
|
||||
termsOfUse=условиями использования
|
||||
phoneLegalAnd=и
|
||||
privacyPolicy=политикой конфиденциальности
|
||||
sendOtp=Получить код
|
||||
otpTitle=Подтверждение телефона
|
||||
otpHeading=Введите код
|
||||
otpSent=Отправили SMS на номер {0}
|
||||
otpDigit=Цифра кода {0}
|
||||
otpResendCountdown=Отправить повторно через
|
||||
otpResend=Отправить код снова
|
||||
authBack=Назад
|
||||
verifyOtp=Подтвердить
|
||||
mockMode=Тестовый режим отправки кода
|
||||
phoneInvalid=Проверьте формат номера телефона.
|
||||
otpInvalid=Код неверен, истёк или уже использован.
|
||||
otpVerifyLimited=Превышен лимит неуспешных авторизаций. Начните процедуру заново.
|
||||
otpCooldown=Повторно отправить СМС можно после обнуления таймера.
|
||||
otpLimited=Превышен лимит попыток авторизации. Попробуйте через 24 часа.
|
||||
otpUnavailable=Сервис подтверждения временно недоступен. Повторите позже.
|
||||
captchaInvalid=Не удалось подтвердить, что запрос отправил человек. Пройдите проверку ещё раз.
|
||||
captchaUnavailable=Проверка пока не загрузилась. Проверьте соединение и повторите.
|
||||
@@ -0,0 +1,75 @@
|
||||
<#import "template.ftl" as layout>
|
||||
<@layout.registrationLayout displayMessage=false; section>
|
||||
<#if section = "header">${msg("otpTitle")}
|
||||
<#elseif section = "form">
|
||||
<link rel="stylesheet" href="${url.resourcesPath}/css/han-login.css?v=6"/>
|
||||
<div class="han-auth-screen han-otp-screen">
|
||||
<button class="han-back-button" type="button" onclick="window.history.back()">
|
||||
<span aria-hidden="true">←</span>
|
||||
<span>${msg("authBack")}</span>
|
||||
</button>
|
||||
|
||||
<div class="han-auth-heading han-otp-heading">
|
||||
<h1>${msg("otpHeading")}</h1>
|
||||
<p>${msg("otpSent", maskedPhone!"***")}</p>
|
||||
</div>
|
||||
|
||||
<form id="kc-otp-form" action="${url.loginAction}" method="post">
|
||||
<input id="otp" name="otp" type="hidden" value=""/>
|
||||
<input type="hidden" name="han_device_id" class="han-device-id" value="${hanDeviceId!""}"/>
|
||||
<input type="hidden" name="han_fingerprint" class="han-fingerprint" value="${hanFingerprint!""}"/>
|
||||
<input type="hidden" name="han_platform" value="${hanPlatform!"web"}"/>
|
||||
<input type="hidden" name="han_os_name" class="han-os-name" value="${hanOsName!""}"/>
|
||||
<input type="hidden" name="han_os_version" class="han-os-version" value="${hanOsVersion!""}"/>
|
||||
<input type="hidden" name="han_app_version" class="han-app-version" value="${hanAppVersion!""}"/>
|
||||
<#if captchaEnabled!false>
|
||||
<input id="han-captcha-token" name="smart-token" type="hidden" value=""/>
|
||||
<div id="han-captcha-container" class="han-captcha"
|
||||
data-sitekey="${captchaClientKey!""}"
|
||||
data-form-id="kc-otp-form"
|
||||
data-submit-id="han-resend-button"
|
||||
data-resend-only="true"></div>
|
||||
<div id="han-captcha-client-error" class="han-error" role="alert" hidden>
|
||||
<span class="han-error-icon">!</span>
|
||||
<span>${msg("captchaUnavailable")}</span>
|
||||
</div>
|
||||
</#if>
|
||||
<div id="han-otp-inputs" class="han-otp-inputs <#if message?has_content>han-shake</#if>"
|
||||
style="grid-template-columns: repeat(${otpCodeLength!6}, minmax(0, 1fr));">
|
||||
<#list 0..((otpCodeLength!6) - 1) as index>
|
||||
<input class="han-otp-digit" type="text" inputmode="numeric" maxlength="1"
|
||||
aria-label="${msg("otpDigit", index + 1)}"
|
||||
<#if index == 0>autocomplete="one-time-code" autofocus</#if>
|
||||
aria-invalid="<#if message?has_content>true<#else>false</#if>"/>
|
||||
</#list>
|
||||
</div>
|
||||
|
||||
<#if message?has_content>
|
||||
<div class="han-error han-otp-error" role="alert">
|
||||
<span class="han-error-icon">!</span>
|
||||
<span>${kcSanitize(message.summary)?no_esc}</span>
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
<div class="han-resend">
|
||||
<p id="han-resend-countdown" data-expires-at="${(otpExpiresAt!0)?c}">
|
||||
${msg("otpResendCountdown")} <strong>—</strong>
|
||||
</p>
|
||||
<button id="han-resend-button" type="submit" name="otp_action" value="resend" hidden>
|
||||
<span aria-hidden="true">↻</span>
|
||||
<span>${msg("otpResend")}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button id="han-otp-submit" class="han-primary-button" type="submit" disabled>
|
||||
${msg("verifyOtp")}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<script src="${url.resourcesPath}/js/han-login.js?v=5"></script>
|
||||
<#if captchaEnabled!false>
|
||||
<script src="https://smartcaptcha.cloud.yandex.ru/captcha.js?render=onload&onload=hanCaptchaOnload"
|
||||
async defer></script>
|
||||
</#if>
|
||||
</#if>
|
||||
</@layout.registrationLayout>
|
||||
@@ -0,0 +1,67 @@
|
||||
<#import "template.ftl" as layout>
|
||||
<@layout.registrationLayout displayMessage=false; section>
|
||||
<#if section = "header">${msg("phoneTitle")}
|
||||
<#elseif section = "form">
|
||||
<link rel="stylesheet" href="${url.resourcesPath}/css/han-login.css?v=6"/>
|
||||
<div class="han-auth-screen han-phone-screen">
|
||||
<div class="han-auth-main">
|
||||
<div class="han-wordmark" aria-label="HAN">
|
||||
<span class="han-wordmark-text">HAN</span>
|
||||
<span class="han-wordmark-dot"></span>
|
||||
</div>
|
||||
<p class="han-brand-subtitle">${msg("authBrandSubtitle")}</p>
|
||||
|
||||
<div class="han-auth-heading">
|
||||
<h1>${msg("phoneWelcome")}</h1>
|
||||
<p>${msg("phoneIntro")}</p>
|
||||
</div>
|
||||
|
||||
<form id="kc-phone-form" action="${url.loginAction}" method="post">
|
||||
<input type="hidden" name="han_device_id" class="han-device-id" value="${hanDeviceId!""}"/>
|
||||
<input type="hidden" name="han_fingerprint" class="han-fingerprint" value="${hanFingerprint!""}"/>
|
||||
<input type="hidden" name="han_platform" value="${hanPlatform!"web"}"/>
|
||||
<input type="hidden" name="han_os_name" class="han-os-name" value="${hanOsName!""}"/>
|
||||
<input type="hidden" name="han_os_version" class="han-os-version" value="${hanOsVersion!""}"/>
|
||||
<input type="hidden" name="han_app_version" class="han-app-version" value="${hanAppVersion!""}"/>
|
||||
<div class="han-field">
|
||||
<label for="phone">${msg("phoneLabel")}</label>
|
||||
<input id="phone" name="phone" type="tel" inputmode="numeric" autocomplete="tel"
|
||||
placeholder="+7 (___) ___ __ __" required autofocus
|
||||
aria-invalid="<#if message?has_content>true<#else>false</#if>"/>
|
||||
<p class="han-field-hint">${msg("phoneCountry")}</p>
|
||||
</div>
|
||||
|
||||
<#if captchaEnabled!false>
|
||||
<input id="han-captcha-token" name="smart-token" type="hidden" value=""/>
|
||||
<div id="han-captcha-container" class="han-captcha"
|
||||
data-sitekey="${captchaClientKey!""}"
|
||||
data-form-id="kc-phone-form"
|
||||
data-submit-id="han-phone-submit"></div>
|
||||
<div id="han-captcha-client-error" class="han-error" role="alert" hidden>
|
||||
<span class="han-error-icon">!</span>
|
||||
<span>${msg("captchaUnavailable")}</span>
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
<#if message?has_content>
|
||||
<div class="han-error" role="alert">
|
||||
<span class="han-error-icon">!</span>
|
||||
<span>${kcSanitize(message.summary)?no_esc}</span>
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
<button id="han-phone-submit" class="han-primary-button" type="submit" disabled>
|
||||
<span>${msg("sendOtp")}</span>
|
||||
<span class="han-button-arrow" aria-hidden="true">→</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="${url.resourcesPath}/js/han-login.js?v=5"></script>
|
||||
<#if captchaEnabled!false>
|
||||
<script src="https://smartcaptcha.cloud.yandex.ru/captcha.js?render=onload&onload=hanCaptchaOnload"
|
||||
async defer></script>
|
||||
</#if>
|
||||
</#if>
|
||||
</@layout.registrationLayout>
|
||||
@@ -0,0 +1,407 @@
|
||||
:root {
|
||||
--han-primary: #030213;
|
||||
--han-text: #252525;
|
||||
--han-muted: #717182;
|
||||
--han-border: rgba(0, 0, 0, 0.12);
|
||||
--han-surface: #ffffff;
|
||||
--han-input: #f3f3f5;
|
||||
--han-error: #d4183d;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html,
|
||||
body,
|
||||
body.login-pf {
|
||||
min-height: 100%;
|
||||
margin: 0;
|
||||
background: var(--han-surface);
|
||||
color: var(--han-text);
|
||||
font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
||||
}
|
||||
|
||||
.login-pf-page,
|
||||
.pf-v5-c-login,
|
||||
.pf-c-login {
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
padding: 0;
|
||||
background: var(--han-surface);
|
||||
}
|
||||
|
||||
.login-pf-page {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.pf-v5-c-login__container,
|
||||
.pf-c-login__container {
|
||||
display: grid;
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
grid-template-areas: "main";
|
||||
grid-template-columns: minmax(0, 390px);
|
||||
justify-content: center;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.login-pf-page .card-pf,
|
||||
.pf-v5-c-login__main,
|
||||
.pf-c-login__main {
|
||||
grid-area: main;
|
||||
width: 100%;
|
||||
max-width: 390px;
|
||||
min-height: 100vh;
|
||||
margin: 0 auto;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
background: var(--han-surface);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
#kc-header,
|
||||
#kc-header-wrapper,
|
||||
#kc-page-title {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#kc-content,
|
||||
#kc-content-wrapper,
|
||||
#kc-form,
|
||||
#kc-form-wrapper {
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.han-auth-screen {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
flex-direction: column;
|
||||
padding: 56px 24px 32px;
|
||||
background: var(--han-surface);
|
||||
}
|
||||
|
||||
.han-phone-screen {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.han-auth-main {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.han-wordmark {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 4px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.han-wordmark-text {
|
||||
color: var(--han-text);
|
||||
font-size: 36px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -1.5px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.han-wordmark-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
margin-bottom: 5px;
|
||||
border-radius: 50%;
|
||||
background: var(--han-primary);
|
||||
}
|
||||
|
||||
.han-brand-subtitle {
|
||||
margin: 0 0 48px;
|
||||
color: var(--han-muted);
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.han-auth-heading {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.han-auth-heading h1 {
|
||||
margin: 0 0 8px;
|
||||
color: var(--han-text);
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.han-auth-heading p {
|
||||
margin: 0;
|
||||
color: var(--han-muted);
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.han-auth-heading p strong,
|
||||
.han-auth-heading p span {
|
||||
color: var(--han-text);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.han-field {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.han-field label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
color: var(--han-text);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.han-field input {
|
||||
appearance: none;
|
||||
width: 100%;
|
||||
height: 56px;
|
||||
padding: 0 16px;
|
||||
border: 1px solid var(--han-border);
|
||||
border-radius: 12px;
|
||||
outline: none;
|
||||
background: var(--han-input);
|
||||
color: var(--han-text);
|
||||
font-size: 16px;
|
||||
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
||||
}
|
||||
|
||||
.han-field input::placeholder {
|
||||
color: rgba(113, 113, 130, 0.6);
|
||||
}
|
||||
|
||||
.han-field input:focus {
|
||||
border-color: rgba(3, 2, 19, 0.5);
|
||||
box-shadow: 0 0 0 3px rgba(3, 2, 19, 0.12);
|
||||
}
|
||||
|
||||
.han-field input[aria-invalid="true"] {
|
||||
border-color: var(--han-error);
|
||||
}
|
||||
|
||||
.han-field-hint {
|
||||
margin: 6px 4px 0;
|
||||
color: var(--han-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.han-primary-button {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 56px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
border: 0;
|
||||
border-radius: 12px;
|
||||
background: var(--han-primary);
|
||||
color: #ffffff;
|
||||
cursor: pointer;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
transition: opacity 0.15s ease, transform 0.1s ease;
|
||||
}
|
||||
|
||||
.han-primary-button:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.han-primary-button:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.han-primary-button:focus-visible,
|
||||
.han-back-button:focus-visible,
|
||||
.han-resend button:focus-visible {
|
||||
outline: 3px solid rgba(3, 2, 19, 0.18);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.han-primary-button:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.han-button-arrow {
|
||||
font-size: 20px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.han-captcha {
|
||||
min-height: 1px;
|
||||
}
|
||||
|
||||
.han-captcha + .han-error {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.han-error {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
margin: 0 0 16px;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid rgba(212, 24, 61, 0.25);
|
||||
border-radius: 12px;
|
||||
background: rgba(212, 24, 61, 0.08);
|
||||
color: var(--han-error);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.han-error[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.han-error-icon {
|
||||
display: inline-flex;
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
flex: 0 0 17px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 1px;
|
||||
border: 1.5px solid currentColor;
|
||||
border-radius: 50%;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.han-otp-screen {
|
||||
padding-top: 52px;
|
||||
}
|
||||
|
||||
.han-back-button {
|
||||
display: inline-flex;
|
||||
align-self: flex-start;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin: 0 0 40px -4px;
|
||||
padding: 4px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--han-muted);
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.han-back-button:hover {
|
||||
color: var(--han-text);
|
||||
}
|
||||
|
||||
.han-otp-heading {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.han-otp-inputs {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.han-otp-digit {
|
||||
appearance: none;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
height: 56px;
|
||||
padding: 0;
|
||||
border: 1px solid var(--han-border);
|
||||
border-radius: 12px;
|
||||
outline: none;
|
||||
background: var(--han-input);
|
||||
color: var(--han-text);
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
text-align: center;
|
||||
transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
|
||||
}
|
||||
|
||||
.han-otp-digit:focus {
|
||||
border-color: rgba(3, 2, 19, 0.55);
|
||||
box-shadow: 0 0 0 3px rgba(3, 2, 19, 0.12);
|
||||
}
|
||||
|
||||
.han-otp-digit.han-filled {
|
||||
background: rgba(3, 2, 19, 0.05);
|
||||
}
|
||||
|
||||
.han-otp-digit[aria-invalid="true"] {
|
||||
border-color: var(--han-error);
|
||||
background: rgba(212, 24, 61, 0.05);
|
||||
color: var(--han-error);
|
||||
}
|
||||
|
||||
.han-otp-error {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.han-resend {
|
||||
display: flex;
|
||||
min-height: 40px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 0 0 24px;
|
||||
color: var(--han-muted);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.han-resend p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.han-resend strong {
|
||||
color: var(--han-text);
|
||||
font-weight: 500;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.han-resend button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--han-primary);
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.han-shake {
|
||||
animation: han-shake 0.4s ease;
|
||||
}
|
||||
|
||||
@keyframes han-shake {
|
||||
0%, 100% { transform: translateX(0); }
|
||||
15% { transform: translateX(-6px); }
|
||||
30% { transform: translateX(6px); }
|
||||
45% { transform: translateX(-5px); }
|
||||
60% { transform: translateX(5px); }
|
||||
75% { transform: translateX(-3px); }
|
||||
90% { transform: translateX(3px); }
|
||||
}
|
||||
|
||||
@media (max-width: 360px) {
|
||||
.han-auth-screen {
|
||||
padding-right: 18px;
|
||||
padding-left: 18px;
|
||||
}
|
||||
|
||||
.han-otp-inputs {
|
||||
gap: 7px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
(function () {
|
||||
function randomId() {
|
||||
if (window.crypto && window.crypto.randomUUID) return window.crypto.randomUUID();
|
||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (char) {
|
||||
var value = Math.random() * 16 | 0;
|
||||
return (char === "x" ? value : (value & 3 | 8)).toString(16);
|
||||
});
|
||||
}
|
||||
|
||||
function initDeviceMetadata() {
|
||||
var deviceId = window.localStorage.getItem("han_device_id") || randomId();
|
||||
var fingerprint = window.localStorage.getItem("han_fingerprint") || randomId();
|
||||
window.localStorage.setItem("han_device_id", deviceId);
|
||||
window.localStorage.setItem("han_fingerprint", fingerprint);
|
||||
document.querySelectorAll(".han-device-id").forEach(function (input) {
|
||||
if (!input.value) input.value = deviceId;
|
||||
});
|
||||
document.querySelectorAll(".han-fingerprint").forEach(function (input) {
|
||||
if (!input.value) input.value = fingerprint;
|
||||
});
|
||||
document.querySelectorAll(".han-os-name").forEach(function (input) {
|
||||
if (!input.value) {
|
||||
input.value = (navigator.userAgentData && navigator.userAgentData.platform) || navigator.platform || "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initPhoneForm() {
|
||||
var input = document.getElementById("phone");
|
||||
var submit = document.getElementById("han-phone-submit");
|
||||
if (!input || !submit) return;
|
||||
|
||||
function formatPhone(value) {
|
||||
var digits = value.replace(/\D/g, "");
|
||||
if (!digits) return "";
|
||||
if (digits.indexOf("8") === 0) digits = "7" + digits.slice(1);
|
||||
else if (digits.indexOf("7") !== 0) digits = "7" + digits;
|
||||
digits = digits.slice(0, 11);
|
||||
|
||||
var result = "+7";
|
||||
if (digits.length > 1) result += " (" + digits.slice(1, 4);
|
||||
if (digits.length >= 4) result += ") " + digits.slice(4, 7);
|
||||
if (digits.length >= 7) result += " " + digits.slice(7, 9);
|
||||
if (digits.length >= 9) result += " " + digits.slice(9, 11);
|
||||
return result;
|
||||
}
|
||||
|
||||
function updatePhone() {
|
||||
input.value = formatPhone(input.value);
|
||||
submit.disabled = input.value.replace(/\D/g, "").length !== 11;
|
||||
}
|
||||
|
||||
input.addEventListener("input", updatePhone);
|
||||
updatePhone();
|
||||
}
|
||||
|
||||
function initOtpForm() {
|
||||
var fields = Array.prototype.slice.call(document.querySelectorAll(".han-otp-digit"));
|
||||
var hidden = document.getElementById("otp");
|
||||
var submit = document.getElementById("han-otp-submit");
|
||||
if (!fields.length || !hidden || !submit) return;
|
||||
|
||||
function syncOtp() {
|
||||
fields.forEach(function (field) {
|
||||
field.classList.toggle("han-filled", Boolean(field.value));
|
||||
});
|
||||
hidden.value = fields.map(function (field) { return field.value; }).join("");
|
||||
submit.disabled = hidden.value.length !== fields.length;
|
||||
}
|
||||
|
||||
fields.forEach(function (field, index) {
|
||||
field.addEventListener("input", function () {
|
||||
var entered = field.value.replace(/\D/g, "");
|
||||
if (entered.length > 1) {
|
||||
entered.slice(0, fields.length).split("").forEach(function (digit, digitIndex) {
|
||||
fields[digitIndex].value = digit;
|
||||
});
|
||||
fields[Math.min(entered.length, fields.length) - 1].focus();
|
||||
} else {
|
||||
field.value = entered.slice(-1);
|
||||
if (field.value && index < fields.length - 1) fields[index + 1].focus();
|
||||
}
|
||||
syncOtp();
|
||||
});
|
||||
|
||||
field.addEventListener("keydown", function (event) {
|
||||
if (event.key === "Backspace" && !field.value && index > 0) {
|
||||
fields[index - 1].value = "";
|
||||
fields[index - 1].focus();
|
||||
syncOtp();
|
||||
}
|
||||
if (event.key === "ArrowLeft" && index > 0) fields[index - 1].focus();
|
||||
if (event.key === "ArrowRight" && index < fields.length - 1) fields[index + 1].focus();
|
||||
});
|
||||
|
||||
field.addEventListener("paste", function (event) {
|
||||
event.preventDefault();
|
||||
var pasted = event.clipboardData.getData("text").replace(/\D/g, "").slice(0, fields.length);
|
||||
fields.forEach(function (otpField) { otpField.value = ""; });
|
||||
pasted.split("").forEach(function (digit, digitIndex) {
|
||||
fields[digitIndex].value = digit;
|
||||
});
|
||||
if (pasted.length) fields[Math.min(pasted.length, fields.length) - 1].focus();
|
||||
syncOtp();
|
||||
});
|
||||
});
|
||||
|
||||
syncOtp();
|
||||
|
||||
var countdown = document.getElementById("han-resend-countdown");
|
||||
var countdownValue = countdown && countdown.querySelector("strong");
|
||||
var resend = document.getElementById("han-resend-button");
|
||||
if (!countdown || !countdownValue || !resend) return;
|
||||
|
||||
var expiresAt = Number(countdown.getAttribute("data-expires-at"));
|
||||
if (!Number.isFinite(expiresAt)) expiresAt = Date.now();
|
||||
var timer;
|
||||
function updateCountdown() {
|
||||
var seconds = Math.max(0, Math.ceil((expiresAt - Date.now()) / 1000));
|
||||
countdownValue.textContent = Math.floor(seconds / 60) + ":" + String(seconds % 60).padStart(2, "0");
|
||||
if (seconds <= 0) {
|
||||
if (timer) window.clearInterval(timer);
|
||||
countdown.hidden = true;
|
||||
resend.hidden = false;
|
||||
}
|
||||
}
|
||||
updateCountdown();
|
||||
if (expiresAt > Date.now()) timer = window.setInterval(updateCountdown, 1000);
|
||||
resend.addEventListener("click", function () {
|
||||
if (document.getElementById("han-captcha-container")) return;
|
||||
window.setTimeout(function () { resend.disabled = true; }, 0);
|
||||
});
|
||||
}
|
||||
|
||||
function initCaptcha() {
|
||||
var container = document.getElementById("han-captcha-container");
|
||||
if (!container) return;
|
||||
var form = document.getElementById(container.getAttribute("data-form-id"));
|
||||
var tokenInput = document.getElementById("han-captcha-token");
|
||||
var error = document.getElementById("han-captcha-client-error");
|
||||
var resendOnly = container.getAttribute("data-resend-only") === "true";
|
||||
var widgetId = null;
|
||||
var executing = false;
|
||||
var pendingSubmitter = null;
|
||||
|
||||
function showError() {
|
||||
executing = false;
|
||||
if (pendingSubmitter) pendingSubmitter.disabled = false;
|
||||
pendingSubmitter = null;
|
||||
if (tokenInput) tokenInput.value = "";
|
||||
if (error) error.hidden = false;
|
||||
}
|
||||
|
||||
window.hanCaptchaOnload = function () {
|
||||
if (!window.smartCaptcha || !form || !tokenInput) {
|
||||
showError();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
widgetId = window.smartCaptcha.render(container, {
|
||||
sitekey: container.getAttribute("data-sitekey"),
|
||||
invisible: true,
|
||||
hl: "ru",
|
||||
callback: function (token) {
|
||||
if (!token || !pendingSubmitter) {
|
||||
showError();
|
||||
return;
|
||||
}
|
||||
var submitter = pendingSubmitter;
|
||||
pendingSubmitter = null;
|
||||
executing = false;
|
||||
tokenInput.value = token;
|
||||
if (submitter.name) {
|
||||
var action = document.createElement("input");
|
||||
action.type = "hidden";
|
||||
action.name = submitter.name;
|
||||
action.value = submitter.value;
|
||||
form.appendChild(action);
|
||||
}
|
||||
HTMLFormElement.prototype.submit.call(form);
|
||||
}
|
||||
});
|
||||
window.smartCaptcha.subscribe(widgetId, "network-error", showError);
|
||||
window.smartCaptcha.subscribe(widgetId, "javascript-error", showError);
|
||||
window.smartCaptcha.subscribe(widgetId, "token-expired", function () {
|
||||
tokenInput.value = "";
|
||||
if (executing) showError();
|
||||
});
|
||||
} catch (_error) {
|
||||
showError();
|
||||
}
|
||||
};
|
||||
|
||||
if (!form || !tokenInput) return;
|
||||
form.addEventListener("submit", function (event) {
|
||||
var submitter = event.submitter;
|
||||
var requiresCaptcha = !resendOnly
|
||||
|| (submitter && submitter.name === "otp_action" && submitter.value === "resend");
|
||||
if (!requiresCaptcha) return;
|
||||
event.preventDefault();
|
||||
if (executing) return;
|
||||
if (error) error.hidden = true;
|
||||
if (widgetId === null || !window.smartCaptcha) {
|
||||
showError();
|
||||
return;
|
||||
}
|
||||
pendingSubmitter = submitter || document.getElementById(container.getAttribute("data-submit-id"));
|
||||
executing = true;
|
||||
if (pendingSubmitter) pendingSubmitter.disabled = true;
|
||||
tokenInput.value = "";
|
||||
try {
|
||||
window.smartCaptcha.execute(widgetId);
|
||||
} catch (_error) {
|
||||
showError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
initDeviceMetadata();
|
||||
initPhoneForm();
|
||||
initOtpForm();
|
||||
initCaptcha();
|
||||
})();
|
||||
@@ -0,0 +1,4 @@
|
||||
parent=keycloak.v2
|
||||
import=common/keycloak
|
||||
styles=css/han-login.css
|
||||
locales=ru
|
||||
Reference in New Issue
Block a user