baseline
This commit is contained in:
31
pages/auth/forgot().php
Normal file
31
pages/auth/forgot().php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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'));
|
||||
Reference in New Issue
Block a user