PHRAS-357 Fix delete user oauth apps & accounts

This commit is contained in:
Nicolas Le Goff
2015-01-20 18:30:11 +01:00
parent 10c3869ca3
commit 3daa96a141

View File

@@ -967,7 +967,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
/** /**
* @todo close all open session
* @return type * @return type
*/ */
public function delete() public function delete()
@@ -1038,6 +1037,24 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$stmt->execute(array(':usr_id' => $this->get_id())); $stmt->execute(array(':usr_id' => $this->get_id()));
$stmt->closeCursor(); $stmt->closeCursor();
// delete created app
$oauthApps = API_OAuth2_Application::load_dev_app_by_user($this->app, $this);
// delete accounts for thos app
foreach ($oauthApps as $oauthApp) {
$account = API_OAuth2_Account::load_with_user($this->app, $oauthApp, $this);
$account->delete();
$oauthApp->delete();
}
// delete any other account
$oauthApps = API_OAuth2_Application::load_app_by_user($this->app, $this);
foreach ($oauthApps as $oauthApp) {
$account = API_OAuth2_Account::load_with_user($this->app, $oauthApp, $this);
$account->delete();
}
unset(self::$_instance[$this->get_id()]); unset(self::$_instance[$this->get_id()]);
return; return;