Repository: airavata-php-gateway Updated Branches: refs/heads/master 36033f5d1 -> 368d722fe
fixing token refresh failure case Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/368d722f Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/368d722f Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/368d722f Branch: refs/heads/master Commit: 368d722fe8e49ee804ceb426c72cc693698ce1c4 Parents: 36033f5 Author: Supun Nakandala <[email protected]> Authored: Thu Sep 3 22:51:02 2015 +0530 Committer: Supun Nakandala <[email protected]> Committed: Thu Sep 3 22:51:02 2015 +0530 ---------------------------------------------------------------------- app/filters.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/368d722f/app/filters.php ---------------------------------------------------------------------- diff --git a/app/filters.php b/app/filters.php index ac98976..a2e92f7 100755 --- a/app/filters.php +++ b/app/filters.php @@ -22,14 +22,19 @@ App::before(function ($request) { $currentTime = time(); if($currentTime > Session::get('oauth-expiration-time')){ $response = WSIS::getRefreshedOAutheToken(Session::get('oauth-refresh-code')); - $accessToken = $response->access_token; - $refreshToken = $response->refresh_token; - $expirationTime = time()/1000 + $response->expires_in - 300; - $authzToken = new Airavata\Model\Security\AuthzToken(); - $authzToken->accessToken = $accessToken; - Session::put('authz-token',$authzToken); - Session::put('oauth-refresh-code',$refreshToken); - Session::put('oauth-expiration-time',$expirationTime); + if(isset($response->access_token)){ + $accessToken = $response->access_token; + $refreshToken = $response->refresh_token; + $expirationTime = time()/1000 + $response->expires_in - 300; + $authzToken = new Airavata\Model\Security\AuthzToken(); + $authzToken->accessToken = $accessToken; + Session::put('authz-token',$authzToken); + Session::put('oauth-refresh-code',$refreshToken); + Session::put('oauth-expiration-time',$expirationTime); + }else{ + Session::flush(); + return Redirect::to('home'); + } } } });
