diff --git a/CHANGELOG.md b/CHANGELOG.md index f7505491b..bbe27debf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - Update db:raw queries to support laravel v10 ([849e5103](https://github.com/pixelfed/pixelfed/commit/849e5103)) - Update RegisterController, store client ip during registration ([d4c967de](https://github.com/pixelfed/pixelfed/commit/d4c967de)) - Update ApiV1Controller, fix account blocks. Closes #4304 ([98739139](https://github.com/pixelfed/pixelfed/commit/98739139)) +- Update RegisterController, improve max_users calculation and add kb page to redirect to if conditions are met ([1bbee6d0](https://github.com/pixelfed/pixelfed/commit/1bbee6d0)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.5 (2023-03-25)](https://github.com/pixelfed/pixelfed/compare/v0.11.4...v0.11.5) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index b4e45934d..0e62abef8 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -180,7 +180,11 @@ class RegisterController extends Controller } $limit = config('pixelfed.max_users'); if($limit) { - abort_if($limit <= User::count(), 404); + $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')); + } + abort_if($limit <= $count, 404); return view('auth.register'); } else { return view('auth.register'); @@ -204,11 +208,11 @@ class RegisterController extends Controller abort_if(BouncerService::checkIp($request->ip()), 404); } - $count = User::count(); + $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 abort(403); + return redirect(route('help.instance-max-users-limit')); } $this->validator($request->all())->validate(); diff --git a/resources/views/site/help/instance-max-users.blade.php b/resources/views/site/help/instance-max-users.blade.php new file mode 100644 index 000000000..bf68e3125 --- /dev/null +++ b/resources/views/site/help/instance-max-users.blade.php @@ -0,0 +1,20 @@ +@extends('site.help.partial.template', ['breadcrumb'=>'Instance User Limit']) + +@section('section') + +
+

Instance User Limit

+
+
+ @if(config('pixelfed.max_users')) +

We have a limit on how many users can join our instance to keep our community healthy.

+ +

If you have been redirected to this page, that means we've reached our user limit or we are not accepting new account registrations at this time.

+ +

Please try again later, or consider joining a different Pixelfed instance.

+ @else +

We do not have a limit on how many users can join our instance.

+ +

If this instance isn't for you, consider joining a different Pixelfed instance.

+ @endif +@endsection diff --git a/routes/web.php b/routes/web.php index c0d12153b..6f5d1fc33 100644 --- a/routes/web.php +++ b/routes/web.php @@ -562,6 +562,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::view('labs-deprecation', 'site.help.labs-deprecation')->name('help.labs-deprecation'); Route::view('tagging-people', 'site.help.tagging-people')->name('help.tagging-people'); Route::view('licenses', 'site.help.licenses')->name('help.licenses'); + Route::view('instance-max-users-limit', 'site.help.instance-max-users')->name('help.instance-max-users-limit'); }); Route::get('newsroom/{year}/{month}/{slug}', 'NewsroomController@show'); Route::get('newsroom/archive', 'NewsroomController@archive');