44use Gt \Session \SessionContainer ;
55
66class 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 ;
913
1014 public function __construct (
1115 string $ clientKey ,
@@ -17,11 +21,42 @@ public function __construct(
1721 $ session = new GlobalSessionContainer ();
1822 }
1923
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 ;
2546 }
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+
2661 }
2762}
0 commit comments