public function revoke_app() { $this->assertLoggedIn(); $this->set('area', 'app'); try { $token = new OAuthToken($this->args('id')); if (!$token->isHydrated()) { throw new Exception("This app does not exist."); } if ($token->get('type') == 2 && $token->get('user_id') != User::$me->id) { throw new Exception("You are not authorized to delete this app."); } $app = $token->getConsumer(); if ($token->get('type') == 2) { $this->setTitle('Revoke App Permissions - ' . $app->getName()); } else { $this->setTitle('Deny App - ' . $app->getName()); } $this->set('token', $token); $this->set('app', $app); if ($this->args('submit')) { if ($token->get('type') == 2) { Activity::log("removed the app named " . $app->getLink() . "."); } else { Activity::log("denied the app named " . $app->getLink() . "."); } $token->delete(); $this->forwardToUrl("/apps"); } } catch (Exception $e) { $this->setTitle('Error'); $this->set('megaerror', $e->getMessage()); } }