4
4
use Gt \Session \SessionContainer ;
5
5
6
6
class Authenticator {
7
- const SESSION_KEY_AUTH_FLOW = "authwave-authflow " ;
8
- const SESSION_KEY_USER_DATA = "authwave-userdata " ;
7
+ const SESSION_KEY = "AUTHWAVE_SESSION " ;
8
+
9
+ private string $ clientKey ;
10
+ private string $ clientSecret ;
11
+ private string $ redirectPath ;
12
+ private SessionData $ sessionData ;
9
13
10
14
public function __construct (
11
15
string $ clientKey ,
@@ -17,11 +21,42 @@ public function __construct(
17
21
$ session = new GlobalSessionContainer ();
18
22
}
19
23
20
- if (!$ session ->contains (GlobalSessionContainer::SESSION_KEY )) {
21
- $ session ->set (
22
- GlobalSessionContainer::SESSION_KEY ,
23
- new SessionData ()
24
- );
24
+ if (!$ session ->contains (self ::SESSION_KEY )) {
25
+ $ session ->set (self ::SESSION_KEY , new SessionData ());
26
+ }
27
+
28
+ $ this ->clientKey = $ clientKey ;
29
+ $ this ->clientSecret = $ clientSecret ;
30
+ $ this ->redirectPath = $ redirectPath ;
31
+ $ this ->sessionData = $ session ->get (self ::SESSION_KEY );
32
+
33
+ if ($ this ->authInProgress ()) {
34
+ $ this ->completeAuth ();
35
+ }
36
+ }
37
+
38
+ public function isLoggedIn ():bool {
39
+ $ userData = null ;
40
+
41
+ try {
42
+ $ userData = $ this ->sessionData ->getUserData ();
43
+ }
44
+ catch (UserDataNotSetException $ exception ) {
45
+ return false ;
25
46
}
47
+
48
+ return isset ($ userData );
49
+ }
50
+
51
+ private function authInProgress ():bool {
52
+ return false ;
53
+ }
54
+
55
+ private function beginAuth ():void {
56
+
57
+ }
58
+
59
+ private function completeAuth ():void {
60
+
26
61
}
27
62
}
0 commit comments