/** * Check if the user is connected with OAuth * if not, it's check if a refresh token cookie * is present and try to reconnect. If not, return * false * @param object $mysqli The mysqli connection object * @return boolean True if the user is connected */ static function isConnected($mysqli) { if (isset($_SESSION['OAuth'])) { return true; } else { if (isset($_COOKIE['APP_REFRESH_TOKEN'])) { $res = OauthConnection::refreshToken($_COOKIE['APP_REFRESH_TOKEN']); if (isset($res['error'])) { return false; } else { OauthConnection::setting($res, $mysqli); return true; } } } }
<?php require_once 'config/config.php'; if (filter_has_var(INPUT_GET, 'error')) { include 'error.php'; } elseif (filter_has_var(INPUT_GET, 'code')) { $code = filter_input(INPUT_GET, 'code'); $token = OauthConnection::getToken($code); OauthConnection::setting($token, $mysqli); header('Location: ' . APP_URI); }