Ensure password resets revoke access to Streaming API

This commit is contained in:
Emelia Smith
2024-01-17 20:38:21 +01:00
committed by Claire
parent fe4a31fdb5
commit 224618fd3b
2 changed files with 12 additions and 0 deletions

View File

@@ -359,6 +359,13 @@ class User < ApplicationRecord
Doorkeeper::AccessToken.by_resource_owner(self).in_batches do |batch|
batch.update_all(revoked_at: Time.now.utc)
Web::PushSubscription.where(access_token_id: batch).delete_all
# Revoke each access token for the Streaming API, since `update_all``
# doesn't trigger ActiveRecord Callbacks:
# TODO: #28793 Combine into a single topic
batch.each do |token|
redis.publish("timeline:access_token:#{token.id}", Oj.dump(event: :kill))
end
end
end