X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Foauthconnectionssettings.php;h=8a206d7101372f3dd69dd9c6af9e92ec203b2051;hb=dd7b95c2cffe7e33f32d841ed8950e09b44b853d;hp=b17729b82160f58e79562601f0518f244e85e65f;hpb=663e4e02a1b3b1c104c2c3db19e524a486c3d981;p=quix0rs-gnu-social.git diff --git a/actions/oauthconnectionssettings.php b/actions/oauthconnectionssettings.php index b17729b821..8a206d7101 100644 --- a/actions/oauthconnectionssettings.php +++ b/actions/oauthconnectionssettings.php @@ -33,6 +33,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { require_once INSTALLDIR . '/lib/connectsettingsaction.php'; require_once INSTALLDIR . '/lib/applicationlist.php'; +require_once INSTALLDIR . '/lib/apioauthstore.php'; /** * Show connected OAuth applications @@ -68,12 +69,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction function title() { - return _('Connected Applications'); - } - - function isReadOnly($args) - { - return true; + return _('Connected applications'); } /** @@ -103,7 +99,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction $application = $profile->getApplications($offset, $limit); - $cnt == 0; + $cnt = 0; if (!empty($application)) { $al = new ApplicationList($application, $user, $this, true); @@ -116,7 +112,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction $this->pagination($this->page > 1, $cnt > APPS_PER_PAGE, $this->page, 'connectionssettings', - array('nickname' => $this->user->nickname)); + array('nickname' => $user->nickname)); } /** @@ -153,6 +149,13 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction } } + /** + * Revoke access to an authorized OAuth application + * + * @param int $appId the ID of the application + * + */ + function revokeAccess($appId) { $cur = common_current_user(); @@ -164,6 +167,8 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction return false; } + // XXX: Transaction here? + $appUser = Oauth_application_user::getByKeys($cur, $app); if (empty($appUser)) { @@ -171,13 +176,14 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction return false; } - $orig = clone($appUser); - $appUser->access_type = 0; // No access - $result = $appUser->update(); + $datastore = new ApiStatusNetOAuthDataStore(); + $datastore->revoke_token($appUser->token, 1); + + $result = $appUser->delete(); if (!$result) { - common_log_db_error($orig, 'UPDATE', __FILE__); - $this->clientError(_('Unable to revoke access for app: ' . $app->id)); + common_log_db_error($orig, 'DELETE', __FILE__); + $this->clientError(sprintf(_('Unable to revoke access for app: %s.'), $app->id)); return false; } @@ -189,7 +195,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction function showEmptyListMessage() { - $message = sprintf(_('You have not authorized any applications to use your account.')); + $message = _('You have not authorized any applications to use your account.'); $this->elementStart('div', 'guide'); $this->raw(common_markup_to_html($message));