generated from jric11/baseProject
ChatGPT's update to harden software and run db updates.
This commit is contained in:
+7
-4
@@ -3,7 +3,8 @@
|
||||
class SignUp extends Base {
|
||||
|
||||
public function createAccount() {
|
||||
$params = ['BTN_SUBMIT' => 'main.php', 'REGISTER_ACTION' => 'SignUp.createAccount'];
|
||||
$kind=$_POST['registration_kind']??(($_GET['membership']??'')==='invited'?'invited':'new_club');
|
||||
$params = ['REGISTRATION_KIND'=>$kind,'BTN_SUBMIT' => 'main.php', 'REGISTER_ACTION' => 'SignUp.createAccount'];
|
||||
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST') {
|
||||
$this->requireCsrf();
|
||||
try {
|
||||
@@ -11,20 +12,22 @@ class SignUp extends Base {
|
||||
if (!$auth->allowAttempt('signup-ip', $_SERVER['REMOTE_ADDR'] ?? '', 5, 3600)) {
|
||||
throw new InvalidArgumentException('Too many account requests. Please try again later.');
|
||||
}
|
||||
$auth->register($_POST);
|
||||
if(!in_array($kind,['new_club','invited'],true))throw new InvalidArgumentException('Choose a valid signup option.');
|
||||
$input=$_POST;$input['registration_kind']=$kind;$auth->register($input);
|
||||
try{(new EmailVerification())->request($_POST['user_email']);}
|
||||
catch(Throwable $e){error_log('Signup verification delivery failed: '.$e->getMessage());}
|
||||
$_SESSION['signup_success'] = true;
|
||||
$_SESSION['signup_success'] = $kind;
|
||||
header('Location: main.php?Xaction=signup', true, 303);
|
||||
exit;
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$params['SIGNUP_ERROR'] = $e->getMessage();
|
||||
foreach (['user_first_name', 'user_last_name', 'user_email', 'user_name'] as $field) {
|
||||
foreach (['user_first_name', 'user_last_name', 'user_email', 'user_name', 'club_name'] as $field) {
|
||||
$params[strtoupper($field)] = $_POST[$field] ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($_SESSION['signup_success'])) {
|
||||
$params['REGISTRATION_KIND'] = $_SESSION['signup_success'];
|
||||
$params['SIGNUP_SUCCESSFUL'] = 'TRUE';
|
||||
unset($_SESSION['signup_success']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user