From 1e3a432087caa20e645e9fb177ffb52e8256e6ca Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 23 May 2018 21:03:20 -0600 Subject: [PATCH] Restrict new registrations with env setting --- .env.example | 2 ++ app/Http/Controllers/Auth/RegisterController.php | 9 +++++++++ config/pixelfed.php | 2 ++ 3 files changed, 13 insertions(+) diff --git a/.env.example b/.env.example index 208dd4efb..db3e5175b 100644 --- a/.env.example +++ b/.env.example @@ -40,6 +40,8 @@ SESSION_SECURE_COOKIE=true API_BASE="/api/1/" API_SEARCH="/api/search" +OPEN_REGISTRATION=true + MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" MIX_APP_URL="${APP_URL}" diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index deabd9502..a2c36356f 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -39,6 +39,7 @@ class RegisterController extends Controller public function __construct() { $this->middleware('guest'); + $this->openRegistrationCheck(); } /** @@ -83,4 +84,12 @@ class RegisterController extends Controller return abort(403); } } + + public function openRegistrationCheck() + { + $openRegistration = config('pixelfed.open_registration'); + if(false == $openRegistration) { + abort(403); + } + } } diff --git a/config/pixelfed.php b/config/pixelfed.php index 0887ca15f..a912a3b26 100644 --- a/config/pixelfed.php +++ b/config/pixelfed.php @@ -15,4 +15,6 @@ return [ 'use_blacklist' => false ], + 'open_registration' => env('OPEN_REGISTRATION', true), + ]; \ No newline at end of file