1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

OAuthServer - implement destructible interface on oauth server client objects

Summary: Fixes T6955.

Test Plan: made an oauth app. made a test authorization. ran bin/remove destroy <phid of oauth client> and there were no errors. verified oauth app and test authorization were both gone.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6955

Differential Revision: https://secure.phabricator.com/D11378
This commit is contained in:
Bob Trahan 2015-01-13 16:17:38 -08:00
parent 38d216f0f1
commit 4655b7e4da

View file

@ -2,7 +2,9 @@
final class PhabricatorOAuthServerClient
extends PhabricatorOAuthServerDAO
implements PhabricatorPolicyInterface {
implements
PhabricatorPolicyInterface,
PhabricatorDestructibleInterface {
protected $secret;
protected $name;
@ -89,4 +91,33 @@ final class PhabricatorOAuthServerClient
return null;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public function destroyObjectPermanently(
PhabricatorDestructionEngine $engine) {
$this->openTransaction();
$this->delete();
$authorizations = id(new PhabricatorOAuthClientAuthorization())
->loadAllWhere('clientPHID = %s', $this->getPHID());
foreach ($authorizations as $authorization) {
$authorization->delete();
}
$tokens = id(new PhabricatorOAuthServerAccessToken())
->loadAllWhere('clientPHID = %s', $this->getPHID());
foreach ($tokens as $token) {
$token->delete();
}
$codes = id(new PhabricatorOAuthServerAuthorizationCode())
->loadAllWhere('clientPHID = %s', $this->getPHID());
foreach ($codes as $code) {
$code->delete();
}
$this->saveTransaction();
}
}