32 lines
1021 B
PHP
32 lines
1021 B
PHP
|
|
<?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');
|
||
|
|
}
|
||
|
|
}
|