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:
@@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user