فهرست منبع

Add max user limit

Daniel Supernault 6 سال پیش
والد
کامیت
12995989c4
2فایلهای تغییر یافته به همراه20 افزوده شده و 2 حذف شده
  1. 10 2
      app/Http/Controllers/Auth/RegisterController.php
  2. 10 0
      config/pixelfed.php

+ 10 - 2
app/Http/Controllers/Auth/RegisterController.php

@@ -116,7 +116,13 @@ class RegisterController extends Controller
      */
      */
     public function showRegistrationForm()
     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);
         return view($view);
     }
     }
 
 
@@ -128,7 +134,9 @@ class RegisterController extends Controller
      */
      */
     public function register(Request $request)
     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);
             return abort(403);
         }
         }
 
 

+ 10 - 0
config/pixelfed.php

@@ -208,6 +208,16 @@ return [
     */
     */
     'cloud_storage' => env('PF_ENABLE_CLOUD', false),
     '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'),
     'media_types' => env('MEDIA_TYPES', 'image/jpeg,image/png,image/gif'),
     'enforce_account_limit' => env('LIMIT_ACCOUNT_SIZE', true),
     'enforce_account_limit' => env('LIMIT_ACCOUNT_SIZE', true),