diff --git a/.env.example b/.env.example index 42a1435..ee505e1 100644 --- a/.env.example +++ b/.env.example @@ -52,3 +52,5 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" YUBICO_CLIENT_ID= YUBICO_SECRET_KEY= + +UPDAT3R_REGISTRATION_ENABLED=true diff --git a/config/updat3r.php b/config/updat3r.php new file mode 100644 index 0000000..1ceaf6d --- /dev/null +++ b/config/updat3r.php @@ -0,0 +1,7 @@ + env('UPDAT3R_REGISTRATION_ENABLED', true), + +]; diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index e84a308..2db0e7e 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -33,5 +33,7 @@ @endsection @section('switch-button') - Register + @if(Route::has('register')) + Register + @endif @endsection diff --git a/resources/views/dashboard/documentation.blade.php b/resources/views/dashboard/documentation.blade.php index 2acdfbf..b81d082 100644 --- a/resources/views/dashboard/documentation.blade.php +++ b/resources/views/dashboard/documentation.blade.php @@ -53,9 +53,9 @@
(Java) Using {{ config('app.name', 'Updat3r') }} for your Minecraft plugin
- + -@endsection \ No newline at end of file +@endsection diff --git a/resources/views/layouts/dashboard.blade.php b/resources/views/layouts/dashboard.blade.php index ec598ca..8736193 100644 --- a/resources/views/layouts/dashboard.blade.php +++ b/resources/views/layouts/dashboard.blade.php @@ -86,8 +86,7 @@ class="user-avatar-md rounded-circle"> diff --git a/routes/web.php b/routes/web.php index 174409c..eef7ab1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -18,7 +18,11 @@ | */ -Auth::routes(); +Auth::routes([ + // enable registration and password reset only if registration is enabled + 'register' => config('updat3r.registration_enabled'), + 'reset' => config('updat3r.registration_enabled') +]); Route::view('/about', 'about'); diff --git a/tests/Feature/RegistrationTest.php b/tests/Feature/RegistrationTest.php deleted file mode 100644 index 04f12f4..0000000 --- a/tests/Feature/RegistrationTest.php +++ /dev/null @@ -1,24 +0,0 @@ -post('/register', [ - 'name' => faker()->name(), - 'email' => faker()->email(), - 'password' => 'Welkom01!', - 'password_confirmation' => 'Welkom01!', - ]) - ->assertSessionHasNoErrors() - ->assertRedirect(RouteServiceProvider::HOME); - -it('is impossible to register with an existing email') - ->tap(fn() => User::factory()->create(['email' => 'wouter@example.com'])) - ->post('/register', [ - 'name' => faker()->name(), - 'email' => 'wouter@example.com', - 'password' => faker()->password(), - 'password_confirmation' => faker()->password(), - ])->assertSessionHasErrors(['email' => 'The email has already been taken.']); diff --git a/tests/Unit/AuthEnabledTest.php b/tests/Unit/AuthEnabledTest.php new file mode 100644 index 0000000..76ddcfa --- /dev/null +++ b/tests/Unit/AuthEnabledTest.php @@ -0,0 +1,9 @@ +skip(fn() => config('updat3r.registration_enabled'), 'Registration is currently enabled') + ->expect(fn($route) => Route::has($route)) + ->toBeFalse() + ->with(['register', 'password.request', 'password.reset']);