Files
reflector-dashboard/auth/verify.php
T

52 lines
1.8 KiB
PHP

<?php
/*
* Reflector Dashboard — web front-end for SvxReflector
* Copyright (C) 2026 SA7AUX (Björn)
* SPDX-License-Identifier: AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version. See the LICENSE file for details.
*/
declare(strict_types=1);
require __DIR__ . '/lib.php';
$tid = trim((string)($_GET['tid'] ?? ''));
$token = trim((string)($_GET['token'] ?? ''));
if ($tid === '' || $token === '') {
http_response_code(400);
echo "Bad request";
exit;
}
$k = rkey("token:verify:$tid");
$h = redis()->hGetAll($k);
if (!is_array($h) || empty($h['uid']) || empty($h['hash'])) {
http_response_code(400);
echo "Invalid or expired token";
exit;
}
if (!hash_equals((string)$h['hash'], token_hash($token))) {
http_response_code(400);
echo "Invalid token";
exit;
}
$uid = (string)$h['uid'];
redis()->hSet(acct_key($uid), 'email_verified', '1');
// Flags: unreg -> reg. An admin must then set normal before the account gets in.
$f = redis()->hGet(acct_key($uid), 'acct_flags');
$f = ($f === false || $f === '') ? 1 : ((int)$f & 0x3F);
redis()->hSet(acct_key($uid), 'acct_flags', (string)((($f & ~1) | 2)));
redis()->del($k);
header('Content-Type: text/html; charset=utf-8');
echo "<!doctype html><meta charset='utf-8'><title>Verified</title><body style='font-family:system-ui;background:#000;color:#0ff;padding:20px;'>
<h2>OK</h2>
<div>Your e-mail is verified. Your account is now registered and waiting for an admin to approve it &mdash; once that is done you can sign in.</div>
<div style='margin-top:12px;'><a href='/svxportal/' style='color:#0ff;'>Back to Reflector Dashboard</a></div>
</body>";