@@ -38,12 +38,14 @@ public function __construct(
3838// need to store it to the current session at all?
3939 $ session ->set (self ::SESSION_KEY , new SessionData ());
4040 }
41+ /** @var SessionData $sessionData*/
42+ $ sessionData = $ session ->get (self ::SESSION_KEY );
4143
4244 $ this ->clientKey = $ clientKey ;
4345 $ this ->currentUriPath = $ currentUriPath ;
4446 $ this ->authwaveHost = $ authwaveHost ;
4547 $ this ->session = $ session ;
46- $ this ->sessionData = $ session -> get ( self :: SESSION_KEY ) ;
48+ $ this ->sessionData = $ sessionData ;
4749 $ this ->redirectHandler = $ redirectHandler ?? new RedirectHandler ();
4850
4951 $ this ->completeAuth ();
@@ -62,10 +64,7 @@ public function isLoggedIn():bool {
6264 return isset ($ userData );
6365 }
6466
65- public function login (
66- Token $ token = null ,
67- string $ loginType = self ::LOGIN_TYPE_DEFAULT
68- ):void {
67+ public function login (Token $ token = null ):void {
6968 if ($ this ->isLoggedIn ()) {
7069 return ;
7170 }
@@ -77,18 +76,15 @@ public function login(
7776 $ this ->sessionData = new SessionData ($ token );
7877 $ this ->session ->set (self ::SESSION_KEY , $ this ->sessionData );
7978
80- $ this ->redirectHandler ->redirect (
81- $ this ->getAuthUri ($ token , $ loginType )
82- );
79+ $ this ->redirectHandler ->redirect ($ this ->getAuthUri ($ token ));
8380 }
8481
85- public function logout ():void {
86- // TODO: Should the logout redirect the user agent to the redirectPath?
82+ public function logout (string $ redirectToPath = "/ " ):void {
8783 $ this ->session ->remove (self ::SESSION_KEY );
88- }
8984
90- public function adminLogin (Token $ token = null ):void {
91- $ this ->login ($ token , self ::LOGIN_TYPE_ADMIN );
85+ $ uri = (new Uri ())
86+ ->withPath ($ redirectToPath );
87+ $ this ->redirectHandler ->redirect ($ uri );
9288 }
9389
9490 public function getUuid ():string {
@@ -106,17 +102,7 @@ public function getField(string $name):?string {
106102 return $ userData ->getField ($ name );
107103 }
108104
109- public function getAuthUri (
110- Token $ token ,
111- string $ loginType = self ::LOGIN_TYPE_DEFAULT
112- ):AbstractProviderUri {
113- if ($ loginType === self ::LOGIN_TYPE_ADMIN ) {
114- return new AdminUri (
115- $ this ->currentUriPath ,
116- $ this ->authwaveHost
117- );
118- }
119-
105+ public function getAuthUri (Token $ token ):AbstractProviderUri {
120106 return new AuthUri (
121107 $ token ,
122108 $ this ->currentUriPath ,
0 commit comments