/** * * @return void */ public function delete() { $this->get_token()->delete(); foreach (API_OAuth2_AuthCode::load_codes_by_account($this->app, $this) as $code) { $code->delete(); } foreach (API_OAuth2_RefreshToken::load_by_account($this->app, $this) as $token) { $token->delete(); } $sql = 'DELETE FROM api_accounts WHERE api_account_id = :account_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute(['account_id' => $this->id]); $stmt->closeCursor(); return; }
/** * * Overrides OAuth2::setAuthCode(). * * @param string $code * @param int $account_id * @param string $redirect_uri * @param string $expires * @param string $scope * @return API_OAuth2_Adapter */ protected function setAuthCode($code, $account_id, $redirect_uri, $expires, $scope = NULL) { $account = new API_OAuth2_Account($this->app, $account_id); $code = API_OAuth2_AuthCode::create($this->app, $account, $code, $expires); $code->set_redirect_uri($redirect_uri)->set_scope($scope); return $this; }
public function testLoad_codes_by_account() { $this->assertTrue(is_array(API_OAuth2_AuthCode::load_codes_by_account(self::$DI['app'], $this->account))); $this->assertTrue(count(API_OAuth2_AuthCode::load_codes_by_account(self::$DI['app'], $this->account)) > 0); }