panda_pal 5.16.5 → 5.16.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed57241456e0fe78d006855d50152d47c8a328b777bf77d16b53e0a59519e766
4
- data.tar.gz: '0748669e4a1e3a83f9e8653b08f8c200b755d9b41a0b61e4dda1b83dbd8859c5'
3
+ metadata.gz: fb2e310fa2edf0bc70f0a4f4e91bc2358b3489cb472571e8f3cc18ee387a04fb
4
+ data.tar.gz: 6baaf5e388cea773faee2f8d65defa4ea64b9feb28412e5f900fc9bbb62d5e34
5
5
  SHA512:
6
- metadata.gz: 5bb3ebb3379973fe51332a46807d6e69c55e4134cca476829231dd3539cdfc21e02af95a91dd32300b4bcd54018dd17061f144318b06577d4f33fae44c5a8ee6
7
- data.tar.gz: 7f924b2f17246b33c5b535c80e0fd6ebef89ccd450d4c78687ae93d2247324ffacb4e8e58c99cfd92f7604ece73e8ebbbd9903af037fa1afa96f8c2063ced03d
6
+ metadata.gz: b19c8454c7333ee1397c78f068db3d1557d422ac8487167d24458ad4e4e6f1857e2c1e16e7ee1793bf50a20fc0a88836e4a4a30cc74a0f6556d970172accde1f
7
+ data.tar.gz: 63fbc3723c539588adf9c312da99a55cd559874913ed2a4e0ea6f13f1ad0850f4d580e199055ffaf2f0b5eb99b00a55df83294272557e2b1129e07d5eedcd25f
@@ -259,6 +259,36 @@ ActiveSupport.on_load(:action_cable) do
259
259
  def tenant
260
260
  @tenant || 'public'
261
261
  end
262
+
263
+ def panda_session
264
+ unless defined?(@panda_session)
265
+ @panda_session = PandaPal::Session.for_request(request, enforce_tenant: :switch)
266
+ @tenant ||= Apartment::Tenant.current
267
+ end
268
+ @panda_session
269
+ end
270
+ end
271
+
272
+ ActionCable::Channel::Base.module_eval do
273
+ delegate :panda_session, to: :connection
274
+
275
+ if defined?(CanCan)
276
+ set_callback(:subscribe, :around) do |_, blk|
277
+ blk.call
278
+ rescue CanCan::AccessDenied
279
+ reject
280
+ end
281
+
282
+ delegate :current_ability, to: :connection
283
+
284
+ def authorize!(*args, **kwargs)
285
+ current_ability.authorize!(*args, **kwargs)
286
+ end
287
+
288
+ def authorized?(*args, **kwargs)
289
+ current_ability.can?(*args, **kwargs)
290
+ end
291
+ end
262
292
  end
263
293
 
264
294
  # Include the Current Tenant in any broadcastings
@@ -281,7 +311,7 @@ ActiveSupport.on_load(:action_cable) do
281
311
  end
282
312
 
283
313
  # Lazily switch any worker threads to the correct tenant when they are working
284
- # Actively calling `switch_tenant` for checks out a DB connection and calls `SET search_path`.
314
+ # Actively calling `switch_tenant` checks out a DB connection and calls `SET search_path`.
285
315
  # The message processing may not interface with the DB, so this would be a huge waste.
286
316
  # Instead, we ensure that the thread will trigger a :checkout if it needs a connection,
287
317
  # at which time we hack-in the correct tenant/schema.
@@ -1,3 +1,3 @@
1
1
  module PandaPal
2
- VERSION = "5.16.5"
2
+ VERSION = "5.16.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda_pal
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.16.5
4
+ version: 5.16.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure CustomDev