Update RegisterController, improve max_users calculation and add kb page to redirect to if conditions are met

This commit is contained in:
Daniel Supernault 2023-04-24 03:58:34 -06:00
parent 85cdaf5f3a
commit 1bbee6d07b
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
3 changed files with 25 additions and 1 deletions

View file

@ -181,6 +181,9 @@ class RegisterController extends Controller
$limit = config('pixelfed.max_users'); $limit = config('pixelfed.max_users');
if($limit) { 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) {
return redirect(route('help.instance-max-users-limit'));
}
abort_if($limit <= $count, 404); abort_if($limit <= $count, 404);
return view('auth.register'); return view('auth.register');
} else { } else {
@ -209,7 +212,7 @@ class RegisterController extends Controller
$limit = config('pixelfed.max_users'); $limit = config('pixelfed.max_users');
if(false == config_cache('pixelfed.open_registration') || $limit && $limit <= $count) { 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(); $this->validator($request->all())->validate();

View file

@ -0,0 +1,20 @@
@extends('site.help.partial.template', ['breadcrumb'=>'Instance User Limit'])
@section('section')
<div class="title">
<h3 class="font-weight-bold">Instance User Limit</h3>
</div>
<hr>
@if(config('pixelfed.max_users'))
<p class="lead">We have a limit on how many users can join our instance to keep our community healthy.</p>
<p class="lead">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.</p>
<p class="lead">Please try again later, or consider <a href="https://pixelfed.org/servers">joining a different Pixelfed instance</a>.</p>
@else
<p class="lead">We do not have a limit on how many users can join our instance.</p>
<p class="lead">If this instance isn't for you, consider <a href="https://pixelfed.org/servers">joining a different Pixelfed instance</a>.</p>
@endif
@endsection

View file

@ -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('labs-deprecation', 'site.help.labs-deprecation')->name('help.labs-deprecation');
Route::view('tagging-people', 'site.help.tagging-people')->name('help.tagging-people'); Route::view('tagging-people', 'site.help.tagging-people')->name('help.tagging-people');
Route::view('licenses', 'site.help.licenses')->name('help.licenses'); 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/{year}/{month}/{slug}', 'NewsroomController@show');
Route::get('newsroom/archive', 'NewsroomController@archive'); Route::get('newsroom/archive', 'NewsroomController@archive');