File tree 3 files changed +48
-0
lines changed
3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 17
17
<file >tests/BladeDirectivesTest.php</file >
18
18
<file >tests/RoutesTest.php</file >
19
19
<file >tests/MiddlewareProtectFromImpersonationTest.php</file >
20
+ <file >tests/SessionGuardTest.php</file >
20
21
</testsuite >
21
22
</testsuites >
22
23
<filter >
Original file line number Diff line number Diff line change @@ -31,8 +31,27 @@ public function quietLogout()
31
31
{
32
32
$ this ->clearUserDataFromStorage ();
33
33
34
+ $ this ->clearPasswordHashes ();
35
+
34
36
$ this ->user = null ;
35
37
36
38
$ this ->loggedOut = true ;
37
39
}
40
+
41
+ /**
42
+ * Removes the stored password hashes from the session.
43
+ *
44
+ * @param void
45
+ * @return void
46
+ */
47
+ protected function clearPasswordHashes ()
48
+ {
49
+ // Sort out password hashes stored in session
50
+ foreach (array_keys (config ('auth.guards ' )) as $ guard ) {
51
+ $ hashName = 'password_hash_ ' . $ guard ;
52
+ if ($ this ->session ->has ($ hashName )) {
53
+ $ this ->session ->remove ($ hashName );
54
+ }
55
+ }
56
+ }
38
57
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Lab404 \Tests ;
4
+
5
+ use Lab404 \Tests \Stubs \Models \User ;
6
+
7
+ class SessionGuardTest extends TestCase
8
+ {
9
+ /** @var String $guard */
10
+ private $ guard ;
11
+
12
+ public function setUp (): void
13
+ {
14
+ parent ::setUp ();
15
+ $ this ->guard = 'web ' ;
16
+ }
17
+
18
+ /** @test */
19
+ public function it_removes_password_hash_from_session ()
20
+ {
21
+ $ hashName = 'password_hash_ ' . $ this ->guard ;
22
+ $ this ->
app [
'auth ' ]->
guard (
$ this ->
guard )->
loginUsingId (
'[email protected] ' );
23
+ $ this ->app ['auth ' ]->guard ($ this ->guard )->getSession ()->put ($ hashName , 'test_hash ' );
24
+ $ this ->app ['auth ' ]->guard ($ this ->guard )->quietLogout ();
25
+ $ this ->assertFalse ($ this ->app ['auth ' ]->guard ($ this ->guard )->check ());
26
+ $ this ->assertFalse ($ this ->app ['auth ' ]->guard ($ this ->guard )->getSession ()->has ($ hashName ));
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments