- Email 2FA is now optional and disabled by default.

Existing and new accounts default to 2FA off.
Registration signs users in directly.
Users can enable it under My Account.
Administrators can manage it under Users & Staff.
Verified password-only and opted-in email-code login flows.
PHP/JavaScript checks and browser console passed.
This commit is contained in:
Ty Clifford
2026-06-10 16:40:22 -04:00
parent 34ca1be9b7
commit 45ef31e61f
10 changed files with 74 additions and 30 deletions
+7
View File
@@ -43,6 +43,13 @@
<small>You can change this any time.</small>
</span>
</label>
<label class="check-control">
<input type="checkbox" name="two_factor_enabled" value="1" <?= checked($currentUser['two_factor_enabled'] ?? 0) ?>>
<span>
<strong>Use email two-factor authentication</strong>
<small>Optional. When enabled, each sign-in requires a six-digit code sent to <?= e($currentUser['email']) ?>.</small>
</span>
</label>
<details class="account-password">
<summary>Change password</summary>
<div class="form-stack">
+3 -1
View File
@@ -15,7 +15,7 @@
<details>
<summary>
<span class="avatar"><?= e(strtoupper(substr((string) $user['full_name'], 0, 1))) ?></span>
<span><strong><?= e($user['full_name']) ?></strong><small><?= e($user['email']) ?> &middot; <?= e($user['phone']) ?></small></span>
<span><strong><?= e($user['full_name']) ?></strong><small><?= e($user['email']) ?> &middot; <?= e($user['phone']) ?> &middot; Email 2FA <?= !empty($user['two_factor_enabled']) ? 'on' : 'off' ?></small></span>
<span class="role-badge"><?= e(ucfirst((string) $user['role'])) ?></span>
<span class="status-dot <?= $user['active'] ? 'is-on' : '' ?>"><?= $user['active'] ? 'Active' : 'Disabled' ?></span>
<span class="edit-label">Edit</span>
@@ -35,6 +35,7 @@
<div class="check-row">
<label class="check-control compact"><input type="checkbox" name="active" value="1" <?= checked($user['active']) ?>><span><strong>Active account</strong></span></label>
<label class="check-control compact"><input type="checkbox" name="newsletter_opt_in" value="1" <?= checked($user['newsletter_opt_in']) ?>><span><strong>News opted in</strong></span></label>
<label class="check-control compact"><input type="checkbox" name="two_factor_enabled" value="1" <?= checked($user['two_factor_enabled'] ?? 0) ?>><span><strong>Email 2FA</strong></span></label>
</div>
<button class="button button-small" type="submit">Save User</button>
</form>
@@ -57,6 +58,7 @@
<div class="check-row">
<label class="check-control compact"><input type="checkbox" name="active" value="1" checked><span><strong>Active account</strong></span></label>
<label class="check-control compact"><input type="checkbox" name="newsletter_opt_in" value="1"><span><strong>News opted in</strong></span></label>
<label class="check-control compact"><input type="checkbox" name="two_factor_enabled" value="1"><span><strong>Email 2FA</strong></span></label>
</div>
<button class="button button-small" type="submit">Create User</button>
</form>
+1 -1
View File
@@ -28,7 +28,7 @@
<input type="number" name="captcha" required inputmode="numeric" autocomplete="off">
</label>
<button class="button button-large button-block" type="submit">Continue Securely</button>
<p class="form-footnote">We will email a six-digit verification code after your password is accepted.</p>
<p class="form-footnote">Email verification is requested only when optional email 2FA is enabled for your account.</p>
<p class="auth-switch">New here? <a href="<?= e(url('/register')) ?>">Create an account</a></p>
</form>
</div>
+1 -1
View File
@@ -5,7 +5,7 @@
<h1>Faster pickup starts here.</h1>
<p>Create an account to keep your contact details, see order history, and hear about new specials.</p>
<ul class="check-list">
<li>Email verification protects your account</li>
<li>Optional email 2FA can be enabled from My Account</li>
<li>Newsletter preferences stay in your control</li>
<li>Your payment details are handled by Square, not stored here</li>
</ul>
+1 -1
View File
@@ -4,7 +4,7 @@
<?= csrf_field() ?>
<div class="verification-icon">6</div>
<div>
<span class="eyebrow">One more step</span>
<span class="eyebrow">Email security check</span>
<h1>Check your email</h1>
<p>Enter the six-digit code we sent you. It is valid for 10 minutes.</p>
</div>