-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_needed.php
More file actions
76 lines (61 loc) · 2.07 KB
/
verify_needed.php
File metadata and controls
76 lines (61 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
require_once __DIR__ . '/db.php';
require_once __DIR__ . '/helpers.php';
require_once __DIR__ . '/email_lib.php';
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
$pdo = db();
// If not logged in, send to login
if (empty($_SESSION['store_user'])) {
header('Location: /login.php');
exit;
}
$userId = is_array($_SESSION['store_user']) ? (int)($_SESSION['store_user']['id'] ?? 0) : (int)$_SESSION['store_user'];
if ($userId < 1) {
header('Location: /logout.php');
exit;
}
$u = gc_email_user_row($pdo, $userId);
if (!$u) {
header('Location: /logout.php');
exit;
}
if (!gc_email_verification_required($pdo) || gc_email_user_is_verified($u)) {
header('Location: /dashboard.php');
exit;
}
$email = trim((string)($u['email'] ?? ''));
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['resend'])) {
csrf_check();
$ok = false;
try {
$ok = gc_email_send_verification($pdo, $userId, true);
} catch (Throwable $t) {}
flash_set($ok ? 'Verification email re-sent.' : 'Failed to send verification email. Contact support.', $ok ? 'success' : 'error');
header('Location: /verify_needed.php');
exit;
}
$PUBLIC_TITLE = 'Verify your email';
$PUBLIC_SIDEBAR = false;
require_once __DIR__ . '/gc_public_top.php';
?>
<div class="card hero">
<h1>Email verification required</h1>
<p class="muted">Please verify your email before using the service.</p>
</div>
<div class="card" style="margin-top:18px; padding:18px;">
<?php flash_show(); ?>
<p style="margin:0 0 10px;">
We sent a verification link to:
<b><?= e($email ?: 'your email address') ?></b>
</p>
<p class="muted" style="margin:0 0 14px;">If you don't see it, check your spam/junk folder.</p>
<form method="post" style="display:flex; gap:10px; flex-wrap:wrap; align-items:center;">
<?= csrf_input() ?>
<button class="btn" type="submit" name="resend" value="1">Resend verification email</button>
<a class="btn" href="/dashboard.php">Back to dashboard</a>
<a class="btn" href="/logout.php">Logout</a>
</form>
</div>
<?php require_once __DIR__ . '/gc_public_bottom.php'; ?>