134 lines
7.3 KiB
HTML
134 lines
7.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Enable Two-Factor Authentication - {{ NAME }} IPAM</title>
|
|
<link rel="icon" type="image/png" href="{{ LOGO_PNG }}">
|
|
<link href="/static/css/output.css" rel="stylesheet">
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" rel="stylesheet">
|
|
</head>
|
|
<body class="bg-gray-300 text-gray-900 dark:bg-zinc-900 dark:text-gray-100 min-h-screen flex flex-col">
|
|
{% include 'header.html' %}
|
|
<div class="flex-1 flex items-center justify-center mx-4">
|
|
<div class="container py-8 max-w-2xl pt-20">
|
|
<div class="bg-gray-200 dark:bg-zinc-800 rounded-2xl shadow-lg p-8">
|
|
<div class="mb-4">
|
|
<a href="/account" class="text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200">
|
|
<i class="fas fa-arrow-left mr-2"></i>Back to Account Settings
|
|
</a>
|
|
</div>
|
|
<h1 class="text-3xl font-bold mb-6 text-center">
|
|
<i class="fas fa-shield-alt mr-2"></i>
|
|
Enable Two-Factor Authentication
|
|
</h1>
|
|
|
|
{% if step == 'generate' %}
|
|
<div class="space-y-4">
|
|
<p class="text-center text-gray-700 dark:text-gray-300">
|
|
Two-factor authentication adds an extra layer of security to your account.
|
|
</p>
|
|
<p class="text-center text-gray-600 dark:text-gray-400 text-sm">
|
|
You'll need an authenticator app like Google Authenticator, Authy, or Microsoft Authenticator.
|
|
</p>
|
|
<form method="POST" class="mt-6">
|
|
<input type="hidden" name="action" value="generate">
|
|
<button type="submit" class="w-full bg-gray-300 hover:bg-gray-400 dark:bg-zinc-700 dark:hover:bg-zinc-600 hover:cursor-pointer px-4 py-3 rounded-lg flex items-center gap-2 justify-center">
|
|
<i class="fas fa-qrcode"></i>
|
|
<span>Generate QR Code</span>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
{% elif step == 'verify' %}
|
|
<div class="space-y-6">
|
|
<div class="text-center">
|
|
<p class="mb-4 text-gray-700 dark:text-gray-300">
|
|
Scan this QR code with your authenticator app:
|
|
</p>
|
|
<div class="flex justify-center mb-4">
|
|
<img src="data:image/png;base64,{{ qr_code }}" alt="QR Code" class="border-4 border-gray-400 dark:border-zinc-600 rounded-lg p-2 bg-white">
|
|
</div>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mb-2">
|
|
Or enter this secret manually:
|
|
</p>
|
|
<div class="bg-gray-300 dark:bg-zinc-900 p-3 rounded-lg font-mono text-sm break-all text-center">
|
|
{{ secret }}
|
|
</div>
|
|
</div>
|
|
|
|
<form method="POST" class="space-y-4">
|
|
<input type="hidden" name="action" value="verify">
|
|
<div>
|
|
<label for="code" class="block text-sm font-medium mb-2">Enter the 6-digit code from your app:</label>
|
|
<input type="text" name="code" id="code" maxlength="6" pattern="[0-9]{6}"
|
|
class="w-full p-3 rounded-lg bg-gray-300 dark:bg-zinc-900 border border-gray-600 text-center text-2xl font-mono tracking-widest"
|
|
placeholder="000000" required autofocus>
|
|
</div>
|
|
{% if error %}
|
|
<div class="bg-red-200 dark:bg-red-900 text-red-800 dark:text-red-200 p-3 rounded-lg">
|
|
<i class="fas fa-exclamation-circle mr-2"></i>{{ error }}
|
|
</div>
|
|
{% endif %}
|
|
<button type="submit" class="w-full bg-gray-300 hover:bg-gray-400 dark:bg-zinc-700 dark:hover:bg-zinc-600 hover:cursor-pointer px-4 py-3 rounded-lg flex items-center gap-2 justify-center">
|
|
<i class="fas fa-check"></i>
|
|
<span>Verify & Enable 2FA</span>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
{% elif step == 'backup_codes' %}
|
|
<div class="space-y-6">
|
|
<div class="bg-yellow-200 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200 p-4 rounded-lg">
|
|
<p class="font-semibold mb-2">
|
|
<i class="fas fa-exclamation-triangle mr-2"></i>
|
|
Important: Save Your Backup Codes
|
|
</p>
|
|
<p class="text-sm">
|
|
These codes can be used to access your account if you lose your authenticator device.
|
|
Store them in a safe place. Each code can only be used once.
|
|
</p>
|
|
</div>
|
|
|
|
<div class="bg-gray-300 dark:bg-zinc-900 p-6 rounded-lg">
|
|
<h2 class="text-xl font-bold mb-4 text-center">Your Backup Codes</h2>
|
|
<div class="grid grid-cols-2 gap-4 font-mono text-center">
|
|
{% for code_pair in backup_codes %}
|
|
<div class="p-3 bg-gray-200 dark:bg-zinc-800 rounded border border-gray-400 dark:border-zinc-600">
|
|
{{ code_pair }}
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex gap-4">
|
|
<button onclick="window.print()" class="flex-1 bg-gray-300 hover:bg-gray-400 dark:bg-zinc-700 dark:hover:bg-zinc-600 hover:cursor-pointer px-4 py-3 rounded-lg flex items-center gap-2 justify-center">
|
|
<i class="fas fa-print"></i>
|
|
<span>Print Codes</span>
|
|
</button>
|
|
<a href="/account" class="flex-1 bg-gray-300 hover:bg-gray-400 dark:bg-zinc-700 dark:hover:bg-zinc-600 hover:cursor-pointer px-4 py-3 rounded-lg flex items-center gap-2 justify-center text-center">
|
|
<i class="fas fa-check"></i>
|
|
<span>Continue</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
// Auto-focus code input and move cursor on input
|
|
const codeInput = document.getElementById('code');
|
|
if (codeInput) {
|
|
codeInput.addEventListener('input', function(e) {
|
|
this.value = this.value.replace(/[^0-9]/g, '');
|
|
if (this.value.length === 6) {
|
|
this.form.submit();
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|