From 712ada6a40e283ec0d21cd3fcf425956dfd5dc1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Purga=C5=82?= Date: Sun, 15 Dec 2024 23:09:13 +0100 Subject: [PATCH] add remember me button --- app/Http/Controllers/AuthenticateSessionController.php | 3 ++- app/Http/Requests/Auth/AuthenticateSessionRequest.php | 1 + resources/js/components/Common/Checkbox.vue | 6 +++++- resources/js/components/Home/LoginForm.vue | 8 ++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/AuthenticateSessionController.php b/app/Http/Controllers/AuthenticateSessionController.php index 61cc4a9e..a4bf1da3 100644 --- a/app/Http/Controllers/AuthenticateSessionController.php +++ b/app/Http/Controllers/AuthenticateSessionController.php @@ -17,8 +17,9 @@ class AuthenticateSessionController extends Controller public function authenticate(AuthenticateSessionRequest $request): RedirectResponse { $credentials = $request->only("email", "password"); + $remember = $request->input("remember", false); - if (auth()->attempt($credentials)) { + if (auth()->attempt($credentials, $remember)) { $request->session()->regenerate(); return redirect()->route("home"); diff --git a/app/Http/Requests/Auth/AuthenticateSessionRequest.php b/app/Http/Requests/Auth/AuthenticateSessionRequest.php index af1ae8ee..53e248c3 100644 --- a/app/Http/Requests/Auth/AuthenticateSessionRequest.php +++ b/app/Http/Requests/Auth/AuthenticateSessionRequest.php @@ -18,6 +18,7 @@ public function rules(): array return [ "email" => ["required", "email", "max:255"], "password" => ["required", "string", "min:8", "max:255"], + "remember" => ["nullable", "boolean"], ]; } } diff --git a/resources/js/components/Common/Checkbox.vue b/resources/js/components/Common/Checkbox.vue index 5f808788..78f49ffe 100644 --- a/resources/js/components/Common/Checkbox.vue +++ b/resources/js/components/Common/Checkbox.vue @@ -1,11 +1,15 @@ + +