diff --git a/src/Http/Controllers/RegisteredUserController.php b/src/Http/Controllers/RegisteredUserController.php index 4df8ba8..84cbb00 100644 --- a/src/Http/Controllers/RegisteredUserController.php +++ b/src/Http/Controllers/RegisteredUserController.php @@ -61,7 +61,7 @@ public function store(Request $request, event(new Registered($user = $creator->create($request->all()))); - $this->guard->login($user); + $this->guard->login($user, $request->boolean('remember')); return app(RegisterResponse::class); } diff --git a/tests/RegisteredUserControllerTest.php b/tests/RegisteredUserControllerTest.php index c832738..be729e1 100644 --- a/tests/RegisteredUserControllerTest.php +++ b/tests/RegisteredUserControllerTest.php @@ -77,4 +77,25 @@ public function test_usernames_will_be_stored_case_insensitive() $response->assertRedirect('/home'); } + + public function test_users_can_be_created_with_remember_option() + { + $this->mock(CreatesNewUsers::class) + ->shouldReceive('create') + ->once() + ->andReturn(Mockery::mock(Authenticatable::class)); + + $this->mock(StatefulGuard::class) + ->shouldReceive('login') + ->with(Mockery::type(Authenticatable::class), true) + ->once(); + + $response = $this->post('/register', [ + 'email' => 'taylor@laravel.com', + 'password' => 'password', + 'remember' => '1', + ]); + + $response->assertRedirect('/home'); + } }