Files
breadcrumb-the-shire/pages/auth/forgot().php
2026-02-04 23:31:53 +01:00

32 lines
916 B
PHP

<?php
use MintyPHP\Buffer;
use MintyPHP\Support\Flash;
use MintyPHP\Session;
use MintyPHP\Router;
use MintyPHP\Http\Request;
use MintyPHP\I18n;
use MintyPHP\Service\PasswordResetService;
$errors = [];
$email = trim((string) ($_POST['email'] ?? ''));
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!Session::checkCsrfToken()) {
$errors[] = t('Form expired, please try again');
} elseif ($email === '' || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors[] = t('Please enter a valid email address');
} else {
PasswordResetService::requestReset($email);
$_SESSION['password_reset_email'] = $email;
Flash::success(
t('If the email exists, a verification code has been sent.'),
'password/verify',
'reset_requested'
);
Router::redirect('password/verify');
}
}
Buffer::set('title', t('Forgot password'));