nexus_cqrs_auth 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1daefed67dc89410ebe057a05c3c35342aff0129283d729784b285dd0b3bd01
4
- data.tar.gz: e6cc7a5d8ae88e769bfeb9efacfaaa43c1886f06866239ad006c5b66bd6d171a
3
+ metadata.gz: 94d379370fd1bbf839449f70e7e1cd89c9b25329b676c1677af766fa367f0c50
4
+ data.tar.gz: e4d381029b3088546bee61e8cfa025c186389d9f45a2dc41cc115f0ccc101f24
5
5
  SHA512:
6
- metadata.gz: 82134ce951fe252f5bdfac8f375e7945d422d7f0aab33b40529bc65e0eee39131f8957a6bacf10d46725427898270004557209de20d0413b47337110e4f089a9
7
- data.tar.gz: d70ab29cc24370907317039af7b23c6590fdf4341e8d6739b045a35dbd89453631264065b4bea8d55dccf5ccd99ad9bcb8e1a3f1b9f8621e1ab323720b01f37f
6
+ metadata.gz: 87b9c424f4f467ffcd0ea920055f38233ba76b0fb44347efb02b9c8673fbac46117b4b81509dc97c475451f0d68fd36125fd8590dc8ad60bbababdc853e16163
7
+ data.tar.gz: 17a6d172b728387267afe182d2259b7d76000fd9a9486619265046704d265e02b8bbbf7b9482bf9222ad72e9e670d2aa2169fb22be8f92e2aa09cb6a551781a2
@@ -14,6 +14,12 @@ module NexusCqrsAuth
14
14
  super_
15
15
  end
16
16
 
17
+ # Helper method for creating a permissions provider object from a query object. This allows certain permissions
18
+ # to be checked inside the command handler, as opposed to inside the policy
19
+ def permission_provider(query)
20
+ PermissionProvider.new(query.metadata[:current_user], query.metadata[:global_permissions])
21
+ end
22
+
17
23
  def pundit_user
18
24
  UserContext.new(@command_user, @global_permissions)
19
25
  end
@@ -12,6 +12,8 @@ module NexusCqrsAuth
12
12
  # has_permission? 'collection:edit', CollectionPermission, collection.id
13
13
  #
14
14
  def has_permission?(permission_key, permission_model = nil, entity_id = nil)
15
+ return false if @user_id.nil?
16
+
15
17
  return true if @global_permissions.include?(permission_key)
16
18
 
17
19
  # check entity-specific permissions
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module NexusCqrsAuth
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexus_cqrs_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Harrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-15 00:00:00.000000000 Z
11
+ date: 2021-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nexus_cqrs