From 946fd6a6c2f402bc8e663c2c9d41bbac25b49971 Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Wed, 11 Aug 2021 16:29:51 -0600 Subject: Implement invite codes for user registration --- includes/form/RegisterForm.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'includes/form/RegisterForm.php') diff --git a/includes/form/RegisterForm.php b/includes/form/RegisterForm.php index 4967048..c1c1966 100644 --- a/includes/form/RegisterForm.php +++ b/includes/form/RegisterForm.php @@ -53,4 +53,20 @@ class RegisterForm extends Form return $result; } + + public function validate_invite_code($invite_code): ?string + { + $result = null; + + if (empty($invite_code)) { + $this->report_error("You need an invite code to register an account."); + } else { + $result = filter_var($invite_code, FILTER_SANITIZE_STRING); + + if (!User::invite_code_exists($result)) { + $this->report_error("Your invite code is invalid."); + } + } + return $result; + } } -- cgit v1.2.3