Skip to content

Commit 047e84e

Browse files
authored
Allow users to log in with 'remember me' option during registration (#579)
1 parent 947e0e4 commit 047e84e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Http/Controllers/RegisteredUserController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function store(Request $request,
6161

6262
event(new Registered($user = $creator->create($request->all())));
6363

64-
$this->guard->login($user);
64+
$this->guard->login($user, $request->boolean('remember'));
6565

6666
return app(RegisterResponse::class);
6767
}

tests/RegisteredUserControllerTest.php

+21
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,25 @@ public function test_usernames_will_be_stored_case_insensitive()
7777

7878
$response->assertRedirect('/home');
7979
}
80+
81+
public function test_users_can_be_created_with_remember_option()
82+
{
83+
$this->mock(CreatesNewUsers::class)
84+
->shouldReceive('create')
85+
->once()
86+
->andReturn(Mockery::mock(Authenticatable::class));
87+
88+
$this->mock(StatefulGuard::class)
89+
->shouldReceive('login')
90+
->with(Mockery::type(Authenticatable::class), true)
91+
->once();
92+
93+
$response = $this->post('/register', [
94+
'email' => '[email protected]',
95+
'password' => 'password',
96+
'remember' => '1',
97+
]);
98+
99+
$response->assertRedirect('/home');
100+
}
80101
}

0 commit comments

Comments
 (0)