- Email verification (regular, business owner), CLI administration
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
require_once __DIR__.'/includes/boot.php';
|
||||
|
||||
$pageTitle = 'Verify Email — My Keyser';
|
||||
$activeNav = '';
|
||||
$token = gs('token');
|
||||
$status = 'error';
|
||||
$title = 'Verification Link Invalid';
|
||||
$message = 'This verification link is invalid or has already been used.';
|
||||
$detail = '';
|
||||
|
||||
if ($token !== '') {
|
||||
$tokenHash = hash('sha256', $token);
|
||||
$row = qone("
|
||||
SELECT evt.*, u.username, u.email, u.member_type
|
||||
FROM email_verification_tokens evt
|
||||
JOIN users u ON u.id = evt.user_id
|
||||
WHERE evt.token_hash=? AND evt.purpose='email_verify'
|
||||
LIMIT 1
|
||||
", [$tokenHash]);
|
||||
|
||||
if ($row && !empty($row['used_at'])) {
|
||||
$title = 'Email Already Verified';
|
||||
$message = 'This verification link has already been used. You can sign in if your account is active.';
|
||||
} elseif ($row && strtotime((string)$row['expires_at']) < time()) {
|
||||
$title = 'Verification Link Expired';
|
||||
$message = 'This verification link has expired. Please register again or contact the site administrator.';
|
||||
} elseif ($row) {
|
||||
qrun("UPDATE users SET email_verified_at=COALESCE(email_verified_at, datetime('now')), is_active=1 WHERE id=?", [(int)$row['user_id']]);
|
||||
qrun("UPDATE email_verification_tokens SET used_at=datetime('now') WHERE id=?", [(int)$row['id']]);
|
||||
|
||||
$user = qone("SELECT * FROM users WHERE id=?", [(int)$row['user_id']]);
|
||||
[$sent, $mailError] = sendRegistrationCompleteEmail($user);
|
||||
|
||||
$status = 'success';
|
||||
$title = 'Email Verified';
|
||||
if (($user['member_type'] ?? 'member') === 'business_owner') {
|
||||
$message = 'Your email is verified and your business-owner account can now sign in.';
|
||||
$detail = 'We sent a follow-up email confirming that our team will call within a couple of business days for business verification.';
|
||||
} else {
|
||||
$message = 'Your email is verified and your account can now sign in.';
|
||||
$detail = 'We sent a thank-you email confirming your registration.';
|
||||
}
|
||||
if (!$sent) {
|
||||
$detail = 'Your account is verified, but the follow-up email could not be sent. Please contact the site administrator if you need help.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include __DIR__.'/includes/header.php';
|
||||
?>
|
||||
<div class="section-sm">
|
||||
<div class="verify-card verify-<?=$status?>">
|
||||
<div class="eyebrow"><?= $status === 'success' ? 'ACCOUNT VERIFIED' : 'EMAIL VERIFICATION' ?></div>
|
||||
<h1><?=e($title)?></h1>
|
||||
<p><?=e($message)?></p>
|
||||
<?php if($detail): ?><p class="verify-detail"><?=e($detail)?></p><?php endif; ?>
|
||||
<div class="flex-row" style="justify-content:center;margin-top:1.5rem">
|
||||
<a href="/login.php" class="btn btn-primary">Sign In</a>
|
||||
<a href="/index.php" class="btn btn-outline">Back Home</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include __DIR__.'/includes/footer.php'; ?>
|
||||
Reference in New Issue
Block a user