Initial commit

This commit is contained in:
2026-04-23 21:38:24 -04:00
commit 63e12a9636
1762 changed files with 1672620 additions and 0 deletions
@@ -0,0 +1,91 @@
@{
ViewData["Title"] = "Two-Factor Authentication";
bool enabled = (bool)ViewBag.TwoFactorEnabled;
bool isSuperAdmin = (bool)ViewBag.IsSuperAdmin;
}
<div class="container py-4" style="max-width:600px">
<h4 class="mb-1"><i class="bi bi-shield-lock me-2 text-primary"></i>Two-Factor Authentication</h4>
<p class="text-muted mb-4">Protect your account with an authenticator app (Google Authenticator, Authy, etc.)</p>
@if (TempData["Success"] != null)
{
<div class="alert alert-success alert-permanent mb-3">@TempData["Success"]</div>
}
@if (TempData["Error"] != null)
{
<div class="alert alert-danger alert-permanent mb-3">@TempData["Error"]</div>
}
@if (enabled)
{
<div class="card border-success shadow-sm mb-4">
<div class="card-body d-flex align-items-center gap-3">
<i class="bi bi-check-circle-fill text-success fs-2"></i>
<div>
<div class="fw-semibold">Two-factor authentication is <span class="text-success">enabled</span></div>
<div class="small text-muted">Your account is protected with an authenticator app.</div>
</div>
</div>
</div>
<div class="card shadow-sm">
<div class="card-header fw-semibold py-2">Disable 2FA</div>
<div class="card-body">
@if (isSuperAdmin)
{
<p class="small text-muted mb-3">
As a SuperAdmin, you must enter a valid authenticator code to disable 2FA.
After disabling, you will be required to set it up again before accessing admin features.
</p>
<form method="post" asp-action="Disable">
@Html.AntiForgeryToken()
<div class="mb-3">
<label class="form-label fw-medium">Authenticator Code</label>
<input type="text" name="confirmationCode" class="form-control"
placeholder="6-digit code" maxlength="6" inputmode="numeric" autocomplete="one-time-code" />
</div>
<button type="submit" class="btn btn-danger"
onclick="return confirm('Disabling 2FA will require you to set it up again. Continue?')">
<i class="bi bi-shield-x me-1"></i>Disable 2FA
</button>
</form>
}
else
{
<form method="post" asp-action="Disable">
@Html.AntiForgeryToken()
<input type="hidden" name="confirmationCode" value="" />
<button type="submit" class="btn btn-outline-danger"
onclick="return confirm('Are you sure you want to disable 2FA?')">
<i class="bi bi-shield-x me-1"></i>Disable 2FA
</button>
</form>
}
</div>
</div>
}
else
{
<div class="card border-warning shadow-sm mb-4">
<div class="card-body d-flex align-items-center gap-3">
<i class="bi bi-exclamation-triangle-fill text-warning fs-2"></i>
<div>
<div class="fw-semibold">Two-factor authentication is <span class="text-danger">not enabled</span></div>
@if (isSuperAdmin)
{
<div class="small text-muted">SuperAdmin accounts are required to have 2FA enabled.</div>
}
else
{
<div class="small text-muted">Enable 2FA to add an extra layer of security to your account.</div>
}
</div>
</div>
</div>
<a asp-action="Setup" class="btn btn-primary btn-lg">
<i class="bi bi-shield-lock me-2"></i>Set Up 2FA Now
</a>
}
</div>
@@ -0,0 +1,58 @@
@{
ViewData["Title"] = "Set Up Two-Factor Authentication";
}
<div class="container py-4" style="max-width:600px">
<h4 class="mb-1"><i class="bi bi-shield-lock me-2 text-primary"></i>Set Up Two-Factor Authentication</h4>
<p class="text-muted mb-4">Scan the QR code below with your authenticator app, then enter the 6-digit code to confirm.</p>
@if (ViewBag.Error != null)
{
<div class="alert alert-danger alert-permanent mb-3">@ViewBag.Error</div>
}
<div class="card shadow-sm mb-4">
<div class="card-body">
<ol class="mb-0 ps-3">
<li class="mb-3">
<strong>Install an authenticator app</strong> on your phone if you haven't already —
<em>Google Authenticator</em>, <em>Microsoft Authenticator</em>, or <em>Authy</em> all work.
</li>
<li class="mb-3">
<strong>Scan this QR code</strong> with your app, or enter the key manually.
<div class="text-center my-3">
<img src="data:image/png;base64,@ViewBag.QrCodeBase64"
alt="QR code for authenticator app"
class="border rounded p-1"
style="width:200px;height:200px" />
</div>
<div class="alert alert-light py-2 small">
<strong>Manual entry key:</strong><br>
<code class="user-select-all">@ViewBag.SharedKey</code>
</div>
</li>
<li>
<strong>Enter the 6-digit code</strong> from your app below to complete setup.
</li>
</ol>
</div>
</div>
<form method="post" asp-action="Setup">
@Html.AntiForgeryToken()
<div class="mb-3">
<label class="form-label fw-semibold">Verification Code</label>
<input type="text" name="verificationCode" class="form-control form-control-lg text-center fw-bold"
placeholder="000000" maxlength="7" inputmode="numeric"
autocomplete="one-time-code" autofocus
style="letter-spacing:0.3em;max-width:200px" />
<div class="form-text">Enter the 6-digit code shown in your authenticator app.</div>
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">
<i class="bi bi-check-lg me-1"></i>Verify &amp; Enable
</button>
<a asp-action="Index" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>