public function testClearPersistentData()
 {
     $persistent_storage = new PersistentStorage(TEST_CLIENT_ID);
     $rand_key = PersistentStorage::$supported_keys[array_rand(PersistentStorage::$supported_keys)];
     $not_support_key = 'not_support';
     $data = 'test-data';
     $persistent_storage->setPersistentData($rand_key, $data);
     $this->assertEquals($persistent_storage->clearPersistentData($rand_key), true);
     $this->assertEquals($persistent_storage->getPersistentData($rand_key, 'default'), 'default');
     $this->assertEquals($persistent_storage->clearPersistentData($not_support_key), false);
 }
Beispiel #2
0
 /**
  * Get the authorization code from the query parameters, if it exists,
  * otherwise return false.
  *
  * @return string|bool The authorization code, or false if the authorization
  * code could not be determined.
  */
 private function getCode()
 {
     if (isset($_REQUEST['code'])) {
         if ($this->state !== null && isset($_REQUEST['state']) && $this->state === $_REQUEST['state']) {
             // Clear CSRF state
             $this->state = null;
             $this->persistent_storage->clearPersistentData('state');
             return $_REQUEST['code'];
         } else {
             error_log('CSRF state token does not match one provided.');
             return false;
         }
     }
     return false;
 }