Files
huntingclubroster/classes/SignUp.php
T
jric11 1e63076123
Security and workflow regressions / regression (push) Has been cancelled
Chat's updates for security, db and workflow
2026-10-20 06:45:30 -04:00

35 lines
1.5 KiB
PHP

<?php
class SignUp extends Base {
public function createAccount() {
$params = ['BTN_SUBMIT' => 'main.php', 'REGISTER_ACTION' => 'SignUp.createAccount'];
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST') {
$this->requireCsrf();
try {
$auth = new AuthService();
if (!$auth->allowAttempt('signup-ip', $_SERVER['REMOTE_ADDR'] ?? '', 5, 3600)) {
throw new InvalidArgumentException('Too many account requests. Please try again later.');
}
$auth->register($_POST);
try{(new EmailVerification())->request($_POST['user_email']);}
catch(Throwable $e){error_log('Signup verification delivery failed: '.$e->getMessage());}
$_SESSION['signup_success'] = true;
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) {
$params[strtoupper($field)] = $_POST[$field] ?? '';
}
}
}
if (!empty($_SESSION['signup_success'])) {
$params['SIGNUP_SUCCESSFUL'] = 'TRUE';
unset($_SESSION['signup_success']);
}
echo $this->applyXSL('<XML/>', $this->getXSL('createAccount'), $params);
exit;
}
}