File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -143,15 +143,27 @@ public function getPublicKey()
143143 return $ this ->_publicKey ;
144144 }
145145
146- public function logout ()
146+ /**
147+ * Logout the current user by identity
148+ * @param bool $globalLogout
149+ * @return bool
150+ * @throws \yii\authclient\InvalidResponseException
151+ * @throws \yii\base\Exception
152+ */
153+ public function logout ($ globalLogout =true )
147154 {
148155 /** @var UserIdentity $identity */
149- $ identity = Yii::$ app ->user ->getIdentity ();
156+ $ identity = Yii::$ app ->user ->identity ;
157+ $ token = $ this ->getAccessToken ()->token ;
158+ if ($ globalLogout )
159+ Yii::$ app ->user ->logout ();
160+
150161 if ($ identity != null && !empty ($ identity ->sid ))
151162 {
152- $ headers = ['Authorization ' => "Bearer " . $ this -> getAccessToken ()-> token ];
163+ $ headers = ['Authorization ' => "Bearer " . $ token ];
153164 $ params = ['sid ' => $ identity ->sid ];
154165 $ this ->sendRequest ("GET " , $ this ->logoutUrl , $ params , $ headers );
155166 }
167+ return true ;
156168 }
157169}
You can’t perform that action at this time.
0 commit comments