コード例 #1
0
ファイル: oauth.php プロジェクト: phpbb/phpbb-core
 /**
  * {@inheritdoc}
  */
 public function unlink_account(array $link_data)
 {
     if (!array_key_exists('oauth_service', $link_data) || !$link_data['oauth_service']) {
         return 'LOGIN_LINK_MISSING_DATA';
     }
     // Remove user specified in $link_data if possible
     $user_id = isset($link_data['user_id']) ? $link_data['user_id'] : $this->user->data['user_id'];
     // Remove the link
     $sql = 'DELETE FROM ' . $this->auth_provider_oauth_token_account_assoc . "\n\t\t\tWHERE provider = '" . $this->db->sql_escape($link_data['oauth_service']) . "'\n\t\t\t\tAND user_id = " . (int) $user_id;
     $this->db->sql_query($sql);
     // Clear all tokens belonging to the user on this servce
     $service_name = 'auth.provider.oauth.service.' . strtolower($link_data['oauth_service']);
     $storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->auth_provider_oauth_token_storage_table, $this->auth_provider_oauth_state_table);
     $storage->clearToken($service_name);
 }
コード例 #2
0
 public function test_retrieve_access_token_by_session_from_db()
 {
     $expected_token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES);
     // Store a token in the database
     $temp_storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->token_storage_table);
     $temp_storage->storeAccessToken($this->service_name, $expected_token);
     unset($temp_storage);
     // Test to see if the token can be retrieved
     $stored_token = $this->token_storage->retrieve_access_token_by_session($this->service_name);
     $this->assertEquals($expected_token, $stored_token);
 }