Skip to content

Commit 212439e

Browse files
author
Phan Van Thanh
committed
Add try catch for send request block
1 parent 66aa77a commit 212439e

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

fproject/authclient/OAuth2.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,20 @@ public function logout($globalLogout=true)
297297
if($globalLogout)
298298
Yii::$app->user->logout();
299299

300-
if($identity != null && !empty($identity->sid))
301-
{
302-
$token = $this->getAccessToken()->token;
303-
$headers = [
304-
'Authorization' => 'Bearer ' . $token
305-
];
306-
$params = [
307-
'sid' => $identity->sid
308-
];
309-
$this->api($this->logoutUrl, 'GET', $params, $headers);
300+
try {
301+
if($identity != null && !empty($identity->sid))
302+
{
303+
$token = $this->getAccessToken()->token;
304+
$headers = [
305+
'Authorization' => 'Bearer ' . $token
306+
];
307+
$params = [
308+
'sid' => $identity->sid
309+
];
310+
$this->api($this->logoutUrl, 'GET', $params, $headers);
311+
}
312+
} catch (Exception $e) {
313+
Yii::$app->response->redirect(Yii::$app->getHomeUrl());
310314
}
311315
return true;
312316
}

0 commit comments

Comments
 (0)