|-------------------------------------------------------------------------- | | Below you will find the "before" and "after" events for the application | which may be used to do any work before or after a request into your | application. Here you may also register your custom route filters. | */ // To invalidate the SOAP WSDL caches // ini_set('soap.wsdl_cache_enabled',0); // ini_set('soap.wsdl_cache_ttl',0); App::before(function ($request) { //Check OAuth token has expired if (Session::has('authz-token')) { $currentTime = time(); if ($currentTime > Session::get('oauth-expiration-time')) { $response = WSIS::getRefreshedOAutheToken(Session::get('oauth-refresh-code')); if (isset($response->access_token)) { $accessToken = $response->access_token; $refreshToken = $response->refresh_token; $expirationTime = time() + $response->expires_in - 300; $authzToken = Session::get('authz-token'); $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'); } } }