File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ class Authenticator {
9
9
private string $ clientKey ;
10
10
private string $ clientSecret ;
11
11
private string $ redirectPath ;
12
+ private SessionContainer $ session ;
12
13
private SessionData $ sessionData ;
13
14
14
15
public function __construct (
@@ -28,6 +29,7 @@ public function __construct(
28
29
$ this ->clientKey = $ clientKey ;
29
30
$ this ->clientSecret = $ clientSecret ;
30
31
$ this ->redirectPath = $ redirectPath ;
32
+ $ this ->session = $ session ;
31
33
$ this ->sessionData = $ session ->get (self ::SESSION_KEY );
32
34
33
35
if ($ this ->authInProgress ()) {
@@ -48,6 +50,10 @@ public function isLoggedIn():bool {
48
50
return isset ($ userData );
49
51
}
50
52
53
+ public function logout ():void {
54
+ $ this ->session ->remove (self ::SESSION_KEY );
55
+ }
56
+
51
57
private function authInProgress ():bool {
52
58
return false ;
53
59
}
Original file line number Diff line number Diff line change @@ -59,4 +59,19 @@ public function testIsLoggedInTrueWhenSessionDataSet() {
59
59
);
60
60
self ::assertTrue ($ sut ->isLoggedIn ());
61
61
}
62
+
63
+ public function testLogoutClearsSession () {
64
+ $ sessionData = self ::createMock (SessionData::class);
65
+ $ _SESSION = [
66
+ Authenticator::SESSION_KEY => $ sessionData
67
+ ];
68
+
69
+ $ sut = new Authenticator (
70
+ "test-key " ,
71
+ "test-secret " ,
72
+ "/ "
73
+ );
74
+ $ sut ->logout ();
75
+ self ::assertEmpty ($ _SESSION );
76
+ }
62
77
}
You can’t perform that action at this time.
0 commit comments