Skip to content

Commit

Permalink
Update RegisterController
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup committed Jun 20, 2023
1 parent 89c3710 commit a6d10f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 11 additions & 6 deletions app/Http/Controllers/Auth/RegisterController.php
Expand Up @@ -178,8 +178,9 @@ public function showRegistrationForm()
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp(request()->ip()), 404);
}
$limit = config('pixelfed.max_users');
if($limit) {
$hasLimit = config('pixelfed.enforce_max_users');
if($hasLimit) {
$limit = config('pixelfed.max_users');
$count = User::where(function($q){ return $q->whereNull('status')->orWhereNotIn('status', ['deleted','delete']); })->count();
if($limit <= $count) {
return redirect(route('help.instance-max-users-limit'));
Expand Down Expand Up @@ -208,13 +209,17 @@ public function register(Request $request)
abort_if(BouncerService::checkIp($request->ip()), 404);
}

$count = User::where(function($q){ return $q->whereNull('status')->orWhereNotIn('status', ['deleted','delete']); })->count();
$limit = config('pixelfed.max_users');
$hasLimit = config('pixelfed.enforce_max_users');
if($hasLimit) {
$count = User::where(function($q){ return $q->whereNull('status')->orWhereNotIn('status', ['deleted','delete']); })->count();
$limit = config('pixelfed.max_users');

if(false == config_cache('pixelfed.open_registration') || $limit && $limit <= $count) {
return redirect(route('help.instance-max-users-limit'));
if($limit && $limit <= $count) {
return redirect(route('help.instance-max-users-limit'));
}
}


$this->validator($request->all())->validate();

event(new Registered($user = $this->create($request->all())));
Expand Down
3 changes: 2 additions & 1 deletion config/pixelfed.php
Expand Up @@ -198,7 +198,8 @@
| 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),

/*
|--------------------------------------------------------------------------
Expand Down

0 comments on commit a6d10f0

Please sign in to comment.