From 77024c56fc944911cde21edef437e572f64a15ea Mon Sep 17 00:00:00 2001 From: Owen Melbourne Date: Mon, 7 Oct 2019 09:39:12 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Feature=20-=20added=20ability=20?= =?UTF-8?q?to=20disable=20registrations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 1 + app/Providers/RouteServiceProvider.php | 11 +++++++++-- config/auth.php | 5 +++++ resources/views/auth/login.blade.php | 6 ++++-- routes/web.php | 2 -- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 2ca07c0..e5e444c 100644 --- a/.env.example +++ b/.env.example @@ -25,3 +25,4 @@ DEBUGBAR_ENABLED=false ENFORCE_DOMAIN=true LOGIN_EMAIL=admin@odin.localhost +REGISTRATIONS_ENABLED=true diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index b36415e..e61643a 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; @@ -52,8 +53,14 @@ public function map() protected function mapWebRoutes() { Route::middleware('web') - ->namespace($this->namespace) - ->group(base_path('routes/web.php')); + ->namespace($this->namespace) + ->group(function () { + Auth::routes([ + 'register' => config('auth.registrations_enabled'), + ]); + + include_once base_path('routes/web.php'); + }); } /** diff --git a/config/auth.php b/config/auth.php index 897dc82..5eef8f8 100644 --- a/config/auth.php +++ b/config/auth.php @@ -2,6 +2,11 @@ return [ + /* + * You can disable the registration of the /register routes here. + */ + 'registrations_enabled' => env('REGISTRATIONS_ENABLED', true), + /* |-------------------------------------------------------------------------- | Authentication Defaults diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 8d32e4c..5f3d7aa 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -39,8 +39,10 @@
- Register or - Reset Password + @if (Route::has('register')) + Register or + @endif + Reset Password
diff --git a/routes/web.php b/routes/web.php index 868fb08..d6fe6c2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -11,8 +11,6 @@ | */ -Auth::routes(); - Route::middleware('auth')->group(function () { Route::redirect('/', '/websites')->name('home'); Route::get('edit-account', '\Maelstrom\Http\Controllers\EditAccountController')->name('maelstrom.edit-account');