Skip to content

Commit

Permalink
Fix redirect to proper ATutor installation
Browse files Browse the repository at this point in the history
  • Loading branch information
herat committed Sep 10, 2016
1 parent 1429248 commit b312d47
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions mods/_standard/calendar/includes/classes/googlecalendar.class.php
Expand Up @@ -76,6 +76,7 @@ public function getAuthSubUrl() {
$client->setScopes(Google_Service_Calendar::CALENDAR);
$client->setAuthConfig('client_secret.json');
$client->setAccessType('offline');
$client->setRedirectUri($this->getCurrentUrl());

$authUrl = $client->createAuthUrl();
return $authUrl;
Expand Down Expand Up @@ -124,21 +125,13 @@ public function getAuthSubHttpClient() {
}

public function isvalidtoken($token) {
//try {
$client = $this->getAuthSubHttpClient();
if ($client->isAccessTokenExpired()) {
$client->fetchAccessTokenWithRefreshToken($this->getRefreshToken($_SESSION['sessionToken']));
$accessToken = $client->getAccessToken();
$_SESSION['sessionToken'] = $accessToken['access_token'].';'.$accessToken['refresh_token'];
}
return true;
// }
// catch (Exception $e ) {
// $qry = "DELETE FROM %scalendar_google_sync WHERE userid=%d";
// queryDB($qry, array(TABLE_PREFIX, $_SESSION['member_id']));
//
// $this->logout();
// }
$client = $this->getAuthSubHttpClient();
if ($client->isAccessTokenExpired()) {
$client->fetchAccessTokenWithRefreshToken($this->getRefreshToken($_SESSION['sessionToken']));
$accessToken = $client->getAccessToken();
$_SESSION['sessionToken'] = $accessToken['access_token'].';'.$accessToken['refresh_token'];
}
return true;
}

/**
Expand Down

0 comments on commit b312d47

Please sign in to comment.