baseline
This commit is contained in:
31
pages/auth/register().php
Normal file
31
pages/auth/register().php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Service\AuthService;
|
||||
use MintyPHP\Support\Flash;
|
||||
use MintyPHP\Router;
|
||||
|
||||
$error = false;
|
||||
if (isset($_POST['email'])) {
|
||||
$firstName = trim((string) ($_POST['first_name'] ?? ''));
|
||||
$lastName = trim((string) ($_POST['last_name'] ?? ''));
|
||||
$email = trim((string) ($_POST['email'] ?? ''));
|
||||
$password = (string) ($_POST['password'] ?? '');
|
||||
$password2 = (string) ($_POST['password2'] ?? '');
|
||||
|
||||
$result = AuthService::register([
|
||||
'first_name' => $firstName,
|
||||
'last_name' => $lastName,
|
||||
'email' => $email,
|
||||
'password' => $password,
|
||||
'password2' => $password2,
|
||||
]);
|
||||
|
||||
if (!($result['ok'] ?? false)) {
|
||||
$error = $result['error'] ?? t('User can not be registered');
|
||||
} else {
|
||||
// Store email in session for verify-email page
|
||||
$_SESSION['email_verification_email'] = $result['email'] ?? $email;
|
||||
Flash::success(t('Registration successful! Please check your email for the verification code.'), 'verify-email', 'registration_success');
|
||||
Router::redirect('verify-email');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user