about summary refs log tree commit diff
path: root/app/controllers/oauth/tokens_controller.rb
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-05-20 03:01:44 -0500
committerGitHub <noreply@github.com>2018-05-20 03:01:44 -0500
commit56a3d2b64bb096bc771c1d3c043a9d44d41c3291 (patch)
tree6917de2e59e69f5ad0dc9b1471a7c7c8659c1af8 /app/controllers/oauth/tokens_controller.rb
parent625c4f36ef394215e65e19157bfaf60e7de94b5f (diff)
parentb481e4fac1c564b8008f6f1d0eea1727ec9faa08 (diff)
Merge pull request #494 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/controllers/oauth/tokens_controller.rb')
-rw-r--r--app/controllers/oauth/tokens_controller.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/controllers/oauth/tokens_controller.rb b/app/controllers/oauth/tokens_controller.rb
new file mode 100644
index 000000000..fa6d58f25
--- /dev/null
+++ b/app/controllers/oauth/tokens_controller.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+class Oauth::TokensController < Doorkeeper::TokensController
+  def revoke
+    unsubscribe_for_token if authorized? && token.accessible?
+    super
+  end
+
+  private
+
+  def unsubscribe_for_token
+    Web::PushSubscription.where(access_token_id: token.id).delete_all
+  end
+end