1
0
mirror of git://f0xx.org/android_cast synced 2026-07-29 04:38:53 +03:00
This commit is contained in:
Anton Afanasyeu
2026-06-10 18:56:36 +02:00
parent 852e1fcaf5
commit 10fade4a4d
8 changed files with 892 additions and 1 deletions

View File

@@ -523,6 +523,13 @@ body { --footer-h: 40px; }
align-items: center;
justify-content: center;
min-height: 100vh;
min-height: 100dvh;
padding: 3rem 16px calc(var(--footer-h, 40px) + 1.5rem);
box-sizing: border-box;
}
.login-page .login-card {
position: relative;
z-index: 6;
}
.login-card {
background: var(--surface);

View File

@@ -162,6 +162,10 @@ if ($route === '/login' && $_SERVER['REQUEST_METHOD'] === 'POST') {
}
if ($route === '/login') {
if (Auth::pending2faUserId() > 0) {
header('Location: ' . $base . '/two-factor');
exit;
}
require __DIR__ . '/../views/login.php';
exit;
}

View File

@@ -101,14 +101,15 @@ final class Auth {
public static function completeTotpLogin(string $code): bool {
$uid = (int) ($_SESSION['pending_2fa_user_id'] ?? 0);
$exp = (int) ($_SESSION['pending_2fa_exp'] ?? 0);
unset($_SESSION['pending_2fa_user_id'], $_SESSION['pending_2fa_exp']);
if ($uid <= 0 || $exp < time()) {
self::clearPending2fa();
return false;
}
$secret = AuthFactors::getTotpSecret($uid);
if ($secret === null || !AuthTotp::verify($secret, $code)) {
return false;
}
self::clearPending2fa();
$stmt = Database::pdo()->prepare('SELECT * FROM users WHERE id = ? LIMIT 1');
$stmt->execute([$uid]);
$row = $stmt->fetch();

View File

@@ -17,6 +17,15 @@ $bp = Auth::basePath();
<script src="<?= h($bp) ?>/assets/js/i18n.js" defer></script>
</head>
<body class="login-page" data-base-path="<?= h($bp) ?>">
<div class="login-locale">
<label class="toolbar-select locale-toolbar-select" data-i18n-title="lang.label" title="Language">
<span class="locale-flag" aria-hidden="true">🇬🇧</span>
<select class="lang-select" data-i18n-aria="lang.label" aria-label="Language">
<option value="en">EN</option>
<option value="ru">RU</option>
</select>
</label>
</div>
<form class="login-card" method="post" action="<?= h($bp) ?>/two-factor">
<h1 data-i18n="twofa.title">Two-factor authentication</h1>
<p class="muted" data-i18n="twofa.hint">Enter the 6-digit code from your authenticator app.</p>