Add closed registration message instead of 403

This commit is contained in:
Daniel Supernault 2018-10-20 23:04:51 -06:00
parent 368b79da5a
commit 9403749d9a
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 43 additions and 5 deletions

View file

@ -39,7 +39,6 @@ class RegisterController extends Controller
public function __construct() public function __construct()
{ {
$this->middleware('guest'); $this->middleware('guest');
$this->openRegistrationCheck();
} }
/** /**
@ -105,11 +104,36 @@ class RegisterController extends Controller
} }
} }
public function openRegistrationCheck() /**
* Show the application registration form.
*
* @return \Illuminate\Http\Response
*/
public function showRegistrationForm()
{ {
$openRegistration = config('pixelfed.open_registration'); $view = config('pixelfed.open_registration') == true ? 'auth.register' : 'site.closed-registration';
if (false == $openRegistration) { return view($view);
abort(403); }
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function register(Request $request)
{
if(false == config('pixelfed.open_registration')) {
return abort(403);
} }
$this->validator($request->all())->validate();
event(new Registered($user = $this->create($request->all())));
$this->guard()->login($user);
return $this->registered($request, $user)
?: redirect($this->redirectPath());
} }
} }

View file

@ -0,0 +1,14 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="error-page py-5 my-5">
<div class="card mx-5">
<div class="card-body p-5 text-center">
<h1>Registration is closed</h1>
<p class="lead mb-0">We have closed registrations on this instance.</p>
</div>
</div>
</div>
</div>
@endsection