Update RegisterController

This commit is contained in:
Daniel Supernault 2023-06-20 05:03:49 -06:00
parent 89c3710d3c
commit a6d10f0389
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 13 additions and 7 deletions

View file

@ -178,8 +178,9 @@ class RegisterController extends Controller
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if(config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp(request()->ip()), 404); abort_if(BouncerService::checkIp(request()->ip()), 404);
} }
$hasLimit = config('pixelfed.enforce_max_users');
if($hasLimit) {
$limit = config('pixelfed.max_users'); $limit = config('pixelfed.max_users');
if($limit) {
$count = User::where(function($q){ return $q->whereNull('status')->orWhereNotIn('status', ['deleted','delete']); })->count(); $count = User::where(function($q){ return $q->whereNull('status')->orWhereNotIn('status', ['deleted','delete']); })->count();
if($limit <= $count) { if($limit <= $count) {
return redirect(route('help.instance-max-users-limit')); return redirect(route('help.instance-max-users-limit'));
@ -208,12 +209,16 @@ class RegisterController extends Controller
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
$hasLimit = config('pixelfed.enforce_max_users');
if($hasLimit) {
$count = User::where(function($q){ return $q->whereNull('status')->orWhereNotIn('status', ['deleted','delete']); })->count(); $count = User::where(function($q){ return $q->whereNull('status')->orWhereNotIn('status', ['deleted','delete']); })->count();
$limit = config('pixelfed.max_users'); $limit = config('pixelfed.max_users');
if(false == config_cache('pixelfed.open_registration') || $limit && $limit <= $count) { if($limit && $limit <= $count) {
return redirect(route('help.instance-max-users-limit')); return redirect(route('help.instance-max-users-limit'));
} }
}
$this->validator($request->all())->validate(); $this->validator($request->all())->validate();

View file

@ -198,7 +198,8 @@ return [
| Allow a maximum number of user accounts. Default: off | Allow a maximum number of user accounts. Default: off
| |
*/ */
'max_users' => env('PF_MAX_USERS', false), 'max_users' => env('PF_MAX_USERS', 1000),
'enforce_max_users' => env('PF_ENFORCE_MAX_USERS', true),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------