diff --git a/app/Http/Controllers/API/UserController.php b/app/Http/Controllers/API/UserController.php
index 8409a0d..7f10014 100644
--- a/app/Http/Controllers/API/UserController.php
+++ b/app/Http/Controllers/API/UserController.php
@@ -72,13 +72,29 @@ class UserController extends BaseController
//If Recptache is enabled check it at the beginning
if(Setting::getSettingValue("recaptcha_v2_register")) {
$reCaptcha = new ReCaptcha(Setting::getSettingValue("recaptcha_v2_secret"));
- $response = $reCaptcha->verify($request->input("g-recaptcha-response"));
+ $captchaResponse = $reCaptcha->verify($request->input("g-recaptcha-response"));
- if(!$response->isSuccess()) {
+ if(!$captchaResponse->isSuccess()) {
throw new HTTPException(400, "Captcha validation failed");
}
}
+ $invite = Invite::query()->where("code", "=", $request->input("invite"))->first();
+ if($invite != null) {
+ if($invite->status != "active") {
+ throw new HTTPException("Invite code invalide");
+ }
+ if(!empty($invite->username) && $request->input("username") != $invite->username) {
+ throw new HTTPException("Invalide username for invite");
+ }
+
+ } else {
+ $setting = Setting::query()->where("name", "=", "registration_possible")->firstOrFail();
+ if(!$setting->value) {
+ throw new HTTPException("400", "Registration disabled");
+ }
+ }
+
$this->validate($request, [
'username' => 'required|max:255|min:5|regex:@^[a-z0-9]*$@|unique:users',
'password' => 'required|min:8',
diff --git a/resources/views/account/register.php b/resources/views/account/register.php
index 4eddea8..6d50563 100644
--- a/resources/views/account/register.php
+++ b/resources/views/account/register.php
@@ -1,4 +1,5 @@
+