diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php index 0db2453..6e14162 100644 --- a/resources/lang/en/auth.php +++ b/resources/lang/en/auth.php @@ -15,6 +15,7 @@ 'sign-in' => [ 'forgot_password' => 'Forgot password?', 'register_now' => 'Not a member? Sign up', + 'remember_me' => 'Remember Me', ], 'register-form' => [ diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index a62992c..f48db79 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -73,14 +73,20 @@ class="w-full" /> -
+ + @slot('label') + @lang('fortify::auth.sign-in.remember_me') + @endslot + + +
@if(Route::has('password.request')) - diff --git a/tests/Actions/AuthenticateUserTest.php b/tests/Actions/AuthenticateUserTest.php index a332bbf..c1cadd1 100644 --- a/tests/Actions/AuthenticateUserTest.php +++ b/tests/Actions/AuthenticateUserTest.php @@ -24,6 +24,7 @@ $this->assertNotNull($loggedUser); $this->assertTrue($user->is($loggedUser)); + $this->assertFalse($request->filled('remember')); }); it('login the user by the email when alt username is set', function () { @@ -44,6 +45,7 @@ $this->assertNotNull($loggedUser); $this->assertTrue($user->is($loggedUser)); + $this->assertFalse($request->filled('remember')); }); it('login the user by the alt username (username)', function () { @@ -64,6 +66,7 @@ $this->assertNotNull($loggedUser); $this->assertTrue($user->is($loggedUser)); + $this->assertFalse($request->filled('remember')); }); it('doesnt login the user by the alt username if not set (username)', function () { @@ -83,6 +86,7 @@ $loggedUser = $authenticator->handle(); $this->assertNull($loggedUser); + $this->assertFalse($request->filled('remember')); }); it('doesnt login the user if password is incorrect', function () { @@ -102,3 +106,28 @@ $this->assertNull($loggedUser); }); + +it('should handle the remember me checkbox', function () { + Config::set('fortify.models.user', \ARKEcosystem\Fortify\Models\User::class); + Config::set('fortify.username_alt', 'username'); + + $user = User::factory()->withUsername()->create(); + + $request = new Request(); + + $this->assertFalse($request->filled('remember')); + + $request->replace([ + 'email' => $user->username, + 'password' => 'password', + 'remember' => true, + ]); + + $authenticator = new AuthenticateUser($request); + $loggedUser = $authenticator->handle(); + + $this->assertNotNull($loggedUser); + $this->assertTrue($user->is($loggedUser)); + + $this->assertTrue($request->filled('remember')); +});