Ejemplo n.º 1
0
 /**
  * Возвращает OAuth2 из текущей сессии
  * @return \OAuth2
  */
 static function getFromSession()
 {
     $res = null;
     if (isset($_SESSION['TRUSTEDNET']['OAUTH'])) {
         $res = unserialize($_SESSION['TRUSTEDNET']['OAUTH']);
         if (!$res->checkToken()) {
             debug("Access token refreshed");
             try {
                 $res->refresh();
             } catch (OAuth2Exception $e) {
                 onOAuth2Exception($e);
             }
         }
     }
     return $res;
 }
Ejemplo n.º 2
0
            if (onUserAuthorized) {
                debug('Event onUserAuthorized');
                onUserAuthorized($user);
            }
            header("Location: " . TRUSTED_AUTHORIZED_REDIRECT);
        } else {
            include_once "./widget.tpl";
        }
    } else {
        $token = OAuth2::getFromSession();
        if (!$token) {
            throw new OAuth2Exception(TRUSTEDNET_ERROR_MSG_TOKEN_NOT_FOUND, TRUSTEDNET_ERROR_CODE_TOKEN_NOT_FOUND, null);
        }
        $token->getAccessToken();
        $token->getUser();
        debug("Token", $token);
    }
} catch (OAuth2Exception $e) {
    if (onOAuth2Exception) {
        onOAuth2Exception($e);
    }
    debug("OAuth2Exception: " . $e->getMessage());
    debug($e->getTrace());
} catch (Exception $e) {
    if (Exception) {
        onException($e);
    }
    debug("Exception: " . $e->getMessage());
    debug($e->getTrace());
}
debug("END");