diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index d9354697a..4ce5538e9 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -116,7 +116,13 @@ class RegisterController extends Controller */ public function showRegistrationForm() { - $view = config('pixelfed.open_registration') == true ? 'auth.register' : 'site.closed-registration'; + $count = User::count(); + $limit = config('pixelfed.max_users'); + if($limit && $limit <= $count) { + $view = 'site.closed-registration'; + } else { + $view = config('pixelfed.open_registration') == true ? 'auth.register' : 'site.closed-registration'; + } return view($view); } @@ -128,7 +134,9 @@ class RegisterController extends Controller */ public function register(Request $request) { - if(false == config('pixelfed.open_registration')) { + $count = User::count(); + $limit = config('pixelfed.max_users'); + if(false == config('pixelfed.open_registration') || $limit && $limit <= $count) { return abort(403); } diff --git a/config/pixelfed.php b/config/pixelfed.php index f6da8cd58..da60ba793 100644 --- a/config/pixelfed.php +++ b/config/pixelfed.php @@ -208,6 +208,16 @@ return [ */ 'cloud_storage' => env('PF_ENABLE_CLOUD', false), + /* + |-------------------------------------------------------------------------- + | Max User Limit + |-------------------------------------------------------------------------- + | + | Allow a maximum number of user accounts. Default: off + | + */ + 'max_users' => env('PF_MAX_USERS', false), + 'media_types' => env('MEDIA_TYPES', 'image/jpeg,image/png,image/gif'), 'enforce_account_limit' => env('LIMIT_ACCOUNT_SIZE', true),