Files
casadoc/public/userportal/api/email-verify-resend.php
T
2026-07-27 21:04:07 +03:00

33 lines
1.0 KiB
PHP

<?php
require __DIR__ . '/_bootstrap.php';
require __DIR__ . '/_codes.php';
require __DIR__ . '/_mail.php';
/**
* @OA\Post(
* path="/email-verify-resend.php",
* tags={"Auth"},
* summary="Re-send the e-mail verification code",
* description="Always answers 200 so the endpoint cannot be used to probe which e-mails are registered. Silently ignored more often than once per 60 seconds.",
* security={},
* @OA\RequestBody(required=true, @OA\JsonContent(
* required={"email"},
* @OA\Property(property="email", type="string", format="email")
* )),
* @OA\Response(response=200, ref="#/components/responses/Success")
* )
*/
require_method('POST');
$email = trim((string) (body()['email'] ?? ''));
if ($email !== '') {
$stmt = $pdo->prepare('SELECT id FROM auth_users WHERE email = ? AND email_verified_at IS NULL LIMIT 1');
$stmt->execute([$email]);
if ($stmt->fetchColumn() && $code = issue_code($pdo, 'auth_email_verifications', $email)) {
send_code_mail($email, $code);
}
}
json_ok();