diff options
author | cflip <36554078+cflip@users.noreply.github.com> | 2021-08-11 16:29:51 -0600 |
---|---|---|
committer | cflip <36554078+cflip@users.noreply.github.com> | 2021-08-11 16:29:51 -0600 |
commit | 946fd6a6c2f402bc8e663c2c9d41bbac25b49971 (patch) | |
tree | 1565fd3230dad24f6df90dc4e3e3d5101d1127b7 /includes/form | |
parent | 2458ca6964401c0bd2cd809d303dfbcaea3ead90 (diff) |
Implement invite codes for user registration
Diffstat (limited to 'includes/form')
-rw-r--r-- | includes/form/RegisterForm.php | 16 |
1 files changed, 16 insertions, 0 deletions
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; + } } |