effective_roles 2.0.5 → 2.2.1

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: '068af67420f4d68373480a8b0f738ae2cc01913b3ec327cff95a01c8dcec0f24'
4
- data.tar.gz: b5cc82efb23a36fa31475bfd27bfe69a8d9d2f41813a3ad3397f131a69669814
3
+ metadata.gz: c7ff9e1eeeb8d78b3f50617feee6d0de9d591478bb8a8cc69f11d2a94bb7c4d0
4
+ data.tar.gz: 66289a8ec1e2206d24a3e612b43b1da5e34311fdaff50973d7995b23052d5ee8
5
5
  SHA512:
6
- metadata.gz: cb8776abf2ed21d03a6c83d51458581143cca3fa0fa2fba64342ec7c05f441fc396a257cf2b4f3d858ff3a5a3bc6479ff1a08af3f5612a6cae8363f6b3f1a8db
7
- data.tar.gz: 3d60cf7e471cf5858ba94f60b959e91000a143551d7a15cbe4f4c2759e8aa7e57e7e381452cd45f9ad67b5bd1a42be8235aa5cc067cba339a8d6ea9c567fe198
6
+ metadata.gz: dc6fccdfa2a4e1b534218b0d37ca175e6b5e339bc493130569ee3e0649c4a4505e52d358d28be3ab2de90c9b2cc7f74beb4c8fed9afffaadc2ab7f3877ed5e33
7
+ data.tar.gz: 0a5c756b3e12e9dd69c156ba2fe8360dd7caf3612a623641c45f08bf18b8fcffe9790687bf344141cd149f877907b41fbb9a2f0270a4546dbf3e555b031e7a66
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2019 Code and Effect Inc.
1
+ Copyright 2021 Code and Effect Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -8,10 +8,6 @@ Includes a mixin for adding authentication for any model.
8
8
 
9
9
  SQL Finders for returning an ActiveRecord::Relation with all permitted records.
10
10
 
11
- Handy formtastic and simple_form helpers for assigning roles.
12
-
13
- Rails 3.2.x and Rails 4
14
-
15
11
 
16
12
  ## Getting Started
17
13
 
@@ -158,8 +154,8 @@ When using assignable roles, you must assign the acts_as_role_restricted resourc
158
154
 
159
155
  You can do this in one of three ways:
160
156
 
161
- 1. Setting resource.current_user = current_user in your controller directly.
162
- 2. Add `before_action :set_effective_roles_current_user` to your ApplicationController
157
+ 1. Setting resource.current_user = current_user in your controller update action directly.
158
+ 2. Add `before_action -> { @thing.current_user = current_user }` to your ApplicationController
163
159
  3. Using `Effective::CrudController` to do this automatically.
164
160
 
165
161
  This restriction is only applied when running within the rails server. Not on rails console or db:seeds.
@@ -319,5 +315,3 @@ This model implements the https://github.com/ryanb/cancan/wiki/Role-Based-Author
319
315
  4. Push to the branch (`git push origin my-new-feature`)
320
316
  5. Bonus points for test coverage
321
317
  6. Create new Pull Request
322
-
323
-
@@ -1,12 +1,17 @@
1
1
  module Admin
2
2
  class RolesController < ApplicationController
3
- before_action :authenticate_user!
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_roles) }
4
5
 
5
- layout (EffectiveRoles.layout.kind_of?(Hash) ? EffectiveRoles.layout[:admin_roles] : EffectiveRoles.layout)
6
+ include Effective::CrudController
7
+
8
+ if (config = EffectiveRoles.layout)
9
+ layout(config.kind_of?(Hash) ? config[:admin] : config)
10
+ end
6
11
 
7
12
  def index
8
13
  @page_title = 'Roles'
9
- EffectiveRoles.authorize!(self, :admin, :effective_roles)
10
14
  end
15
+
11
16
  end
12
17
  end
@@ -101,4 +101,108 @@ module EffectiveRolesHelper
101
101
  klass.respond_to?(:name) ? klass.name : klass.to_s
102
102
  end
103
103
 
104
+ # This is used by the effective_roles_summary_table helper method
105
+ def effective_roles_authorization_level(controller, role, resource)
106
+ authorization_method = EffectiveResources.authorization_method
107
+
108
+ raise('expected an authorization method') unless (authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol))
109
+ return :unknown unless (controller.current_user rescue nil).respond_to?(:roles=)
110
+
111
+ # Store the current ability (cancan support) and roles
112
+ current_ability = controller.instance_variable_get(:@current_ability)
113
+ current_user = controller.instance_variable_get(:@current_user)
114
+ current_user_roles = controller.current_user.roles
115
+
116
+ # Set up the user, so the check is done with the desired permission level
117
+ controller.instance_variable_set(:@current_ability, nil)
118
+
119
+ level = nil
120
+
121
+ case role
122
+ when :signed_in
123
+ controller.current_user.roles = []
124
+ when :public
125
+ controller.instance_variable_set(:@current_user, nil)
126
+
127
+ if defined?(EffectiveLogging)
128
+ EffectiveLogging.supressed { (controller.request.env['warden'].set_user(false) rescue nil) }
129
+ else
130
+ (controller.request.env['warden'].set_user(false) rescue nil)
131
+ end
132
+ else
133
+ controller.current_user.roles = [role]
134
+ end
135
+
136
+ # Find the actual authorization level
137
+ level = effective_roles_item_authorization_level(controller, role, resource, authorization_method)
138
+
139
+ # Restore the existing current_user stuff
140
+ if role == :public
141
+ ActiveRecord::Base.transaction do
142
+ if defined?(EffectiveLogging)
143
+ EffectiveLogging.supressed { (controller.request.env['warden'].set_user(current_user) rescue nil) }
144
+ else
145
+ (controller.request.env['warden'].set_user(current_user) rescue nil)
146
+ end
147
+
148
+ raise ActiveRecord::Rollback
149
+ end
150
+ end
151
+
152
+ controller.instance_variable_set(:@current_ability, current_ability)
153
+ controller.instance_variable_set(:@current_user, current_user)
154
+ controller.current_user.roles = current_user_roles
155
+
156
+ level
157
+ end
158
+
159
+ def effective_roles_item_authorization_level(controller, role, resource, auth_method)
160
+ resource = (resource.new() rescue resource) if resource.kind_of?(ActiveRecord::Base)
161
+
162
+ # Custom actions
163
+ if resource.kind_of?(Hash)
164
+ resource.each do |key, value|
165
+ return (controller.instance_exec(controller, key, value, &auth_method) rescue false) ? :yes : :no
166
+ end
167
+ end
168
+
169
+ # Check for Manage
170
+ return :manage if (
171
+ (controller.instance_exec(controller, :create, resource, &auth_method) rescue false) &&
172
+ (controller.instance_exec(controller, :update, resource, &auth_method) rescue false) &&
173
+ (controller.instance_exec(controller, :show, resource, &auth_method) rescue false) &&
174
+ (controller.instance_exec(controller, :destroy, resource, &auth_method) rescue false)
175
+ )
176
+
177
+ # Check for Update
178
+ return :update if (controller.instance_exec(controller, :update, resource, &auth_method) rescue false)
179
+
180
+ # Check for Update Own
181
+ if resource.respond_to?('user=')
182
+ resource.user = controller.current_user
183
+ return :update_own if (controller.instance_exec(controller, :update, resource, &auth_method) rescue false)
184
+ resource.user = nil
185
+ elsif resource.respond_to?('user_id=')
186
+ resource.user_id = controller.current_user.id
187
+ return :update_own if (controller.instance_exec(controller, :update, resource, &auth_method) rescue false)
188
+ resource.user_id = nil
189
+ elsif resource.class.name.end_with?('User')
190
+ return :update_own if (controller.instance_exec(controller, :update, controller.current_user, &auth_method) rescue false)
191
+ end
192
+
193
+ # Check for Create
194
+ return :create if (controller.instance_exec(controller, :create, resource, &auth_method) rescue false)
195
+
196
+ # Check for Show
197
+ return :show if (controller.instance_exec(controller, :show, resource, &auth_method) rescue false)
198
+
199
+ # Check for Index
200
+ return :index if (controller.instance_exec(controller, :index, resource, &auth_method) rescue false)
201
+
202
+ # Check for Destroy
203
+ return :destroy if (controller.instance_exec(controller, :destroy, resource, &auth_method) rescue false)
204
+
205
+ :none
206
+ end
207
+
104
208
  end
@@ -29,13 +29,11 @@ module ActsAsRoleRestricted
29
29
 
30
30
  validates :roles_mask, numericality: true, allow_nil: true
31
31
 
32
- validate(if: -> { changes.include?(:roles_mask) && EffectiveRoles.assignable_roles_present?(self) }) do
33
- user = current_user || EffectiveRoles.current_user || (EffectiveLogging.current_user if defined?(EffectiveLogging))
34
-
32
+ validate(if: -> { changes.include?(:roles_mask) && EffectiveRoles.assignable_roles_present?(self) && current_user.present? }) do
35
33
  roles_was = EffectiveRoles.roles_for(changes[:roles_mask].first)
36
34
  changed = (roles + roles_was) - (roles & roles_was) # XOR
37
35
 
38
- assignable = EffectiveRoles.assignable_roles_collection(self, user) # Returns all roles when user is blank
36
+ assignable = EffectiveRoles.assignable_roles_collection(self, current_user) # Returns all roles when user is blank
39
37
  unauthorized = changed - assignable
40
38
 
41
39
  authorized = roles.dup
@@ -45,7 +43,7 @@ module ActsAsRoleRestricted
45
43
  Rails.logger.info "\e[31m unassignable roles: #{unauthorized.map { |role| ":#{role}" }.to_sentence}"
46
44
  end
47
45
 
48
- if unauthorized.present? && user.blank? && defined?(Rails::Server)
46
+ if unauthorized.present? && current_user.blank? && defined?(Rails::Server)
49
47
  self.errors.add(:roles, 'current_user must be present when assigning roles')
50
48
  end
51
49
 
@@ -131,4 +129,3 @@ module ActsAsRoleRestricted
131
129
  end
132
130
 
133
131
  end
134
-
@@ -13,4 +13,5 @@
13
13
  %td= effective_roles_authorization_label(klass)
14
14
  - roles.each do |role|
15
15
  %td.text-center
16
- = effective_roles_authorization_badge(EffectiveRoles.authorization_level(controller, role, klass))
16
+ - level = effective_roles_authorization_level(controller, role, klass)
17
+ = effective_roles_authorization_badge(level)
@@ -67,34 +67,8 @@ EffectiveRoles.setup do |config|
67
67
  # }
68
68
 
69
69
  # Authorization Method
70
- #
71
- # This doesn't have anything to do with the roles themselves.
72
- # It's only used in two places:
73
- # - For the effective_roles_summary_table() helper method
74
- # - The /admin/roles page check
75
- #
76
- # It should match the authorization check used by your application
77
- #
78
- # This method is called by all controller actions with the appropriate action and resource
79
- # If the method returns false, an Effective::AccessDenied Error will be raised (see README.md for complete info)
80
- #
81
- # Use via Proc (and with CanCan):
82
- # config.authorization_method = Proc.new { |controller, action, resource| can?(action, resource) }
83
- #
84
- # Use via custom method:
85
- # config.authorization_method = :my_authorization_method
86
- #
87
- # And then in your application_controller.rb:
88
- #
89
- # def my_authorization_method(action, resource)
90
- # current_user.is?(:admin)
91
- # end
92
- #
93
- # Or disable the check completely:
94
- # config.authorization_method = false
95
- config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) } # CanCanCan
70
+ # This gem serves an /admin/roles endpoint that calls EffectiveResources.authorize!
96
71
 
97
72
  # Layout Settings
98
- # Configure the Layout per controller, or all at once
99
- config.layout = 'application'
73
+ # config.layout = 'admin'
100
74
  end
@@ -1,5 +1,3 @@
1
- require 'effective_roles/set_current_user'
2
-
3
1
  module EffectiveRoles
4
2
  class Engine < ::Rails::Engine
5
3
  engine_name 'effective_roles'
@@ -11,18 +9,8 @@ module EffectiveRoles
11
9
  end
12
10
  end
13
11
 
14
- # Register the log_page_views concern so that it can be called in ActionController or elsewhere
15
- initializer 'effective_logging.log_changes_action_controller' do |app|
16
- Rails.application.config.to_prepare do
17
- ActiveSupport.on_load :action_controller do
18
- require 'effective_roles/set_current_user'
19
- ActionController::Base.include(EffectiveRoles::SetCurrentUser::ActionController)
20
- end
21
- end
22
- end
23
-
24
12
  # Set up our default configuration options.
25
- initializer "effective_roles.defaults", :before => :load_config_initializers do |app|
13
+ initializer "effective_roles.defaults", before: :load_config_initializers do |app|
26
14
  eval File.read("#{config.root}/config/effective_roles.rb")
27
15
  end
28
16
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveRoles
2
- VERSION = '2.0.5'.freeze
2
+ VERSION = '2.2.1'.freeze
3
3
  end
@@ -1,59 +1,30 @@
1
+ require 'effective_resources'
1
2
  require 'effective_roles/engine'
2
3
  require 'effective_roles/version'
3
4
 
4
5
  module EffectiveRoles
5
- mattr_accessor :roles
6
- mattr_accessor :role_descriptions
7
- mattr_accessor :assignable_roles
8
6
 
9
- mattr_accessor :layout
10
- mattr_accessor :authorization_method
11
-
12
- def self.setup
13
- yield self
7
+ def self.config_keys
8
+ [:roles, :role_descriptions, :assignable_roles, :layout]
14
9
  end
15
10
 
11
+ include EffectiveGem
12
+
16
13
  def self.permitted_params
17
14
  { roles: [] }
18
15
  end
19
16
 
20
- def self.authorized?(controller, action, resource)
21
- @_exceptions ||= [Effective::AccessDenied, (CanCan::AccessDenied if defined?(CanCan)), (Pundit::NotAuthorizedError if defined?(Pundit))].compact
22
-
23
- return !!authorization_method unless authorization_method.respond_to?(:call)
24
- controller = controller.controller if controller.respond_to?(:controller)
25
-
26
- begin
27
- !!(controller || self).instance_exec((controller || self), action, resource, &authorization_method)
28
- rescue *@_exceptions
29
- false
30
- end
31
- end
32
-
33
- def self.authorize!(controller, action, resource)
34
- raise Effective::AccessDenied unless authorized?(controller, action, resource)
35
- end
36
-
37
- # This is set by the "set_effective_roles_current_user" before_filter.
38
- def self.current_user=(user)
39
- @effective_roles_current_user = user
40
- end
41
-
42
- def self.current_user
43
- @effective_roles_current_user
44
- end
45
-
46
17
  # This method converts whatever is given into its roles
47
18
  # Pass an object, Integer, or Symbol to find corresponding role
48
19
  def self.roles_for(obj)
49
20
  if obj.respond_to?(:is_role_restricted?)
50
21
  obj.roles
51
22
  elsif obj.kind_of?(Integer)
52
- roles.reject { |r| (obj & 2**roles.index(r)).zero? }
23
+ roles.reject { |r| (obj & 2 ** config.roles.index(r)).zero? }
53
24
  elsif obj.kind_of?(Symbol)
54
- [roles.find { |role| role == obj }].compact
25
+ Array(roles.find { |role| role == obj })
55
26
  elsif obj.kind_of?(String)
56
- [roles.find { |role| role == obj.to_sym }].compact
27
+ Array(roles.find { |role| role == obj.to_sym })
57
28
  elsif obj.kind_of?(Array)
58
29
  obj.map { |obj| roles_for(obj) }.flatten.compact
59
30
  elsif obj.nil?
@@ -65,10 +36,10 @@ module EffectiveRoles
65
36
 
66
37
  # EffectiveRoles.roles_mask_for(:admin, :member)
67
38
  def self.roles_mask_for(*roles)
68
- roles_for(roles).map { |r| 2**EffectiveRoles.roles.index(r) }.sum
39
+ roles_for(roles).map { |r| 2 ** config.roles.index(r) }.sum
69
40
  end
70
41
 
71
- def self.roles_collection(resource, current_user = nil, only: nil, except: nil, multiple: nil)
42
+ def self.roles_collection(resource, current_user = nil, only: nil, except: nil, multiple: nil, skip_disabled: nil)
72
43
  if assignable_roles.present?
73
44
  raise('expected object to respond to is_role_restricted?') unless resource.respond_to?(:is_role_restricted?)
74
45
  raise('expected current_user to respond to is_role_restricted?') if current_user && !current_user.respond_to?(:is_role_restricted?)
@@ -78,15 +49,19 @@ module EffectiveRoles
78
49
  except = Array(except).compact
79
50
  multiple = resource.acts_as_role_restricted_options[:multiple] if multiple.nil?
80
51
  assignable = assignable_roles_collection(resource, current_user, multiple: multiple)
52
+ skip_disabled = assignable_roles.kind_of?(Hash) if skip_disabled.nil?
81
53
 
82
54
  roles.map do |role|
83
55
  next if only.present? && !only.include?(role)
84
56
  next if except.present? && except.include?(role)
85
57
 
58
+ disabled = !assignable.include?(role)
59
+ next if disabled && skip_disabled
60
+
86
61
  [
87
62
  "#{role}<p class='help-block text-muted'>#{role_description(role, resource)}</p>".html_safe,
88
63
  role,
89
- ({:disabled => :disabled} unless assignable.include?(role))
64
+ ({:disabled => :disabled} if disabled)
90
65
  ]
91
66
  end.compact
92
67
  end
@@ -94,14 +69,12 @@ module EffectiveRoles
94
69
  def self.assignable_roles_collection(resource, current_user = nil, multiple: nil)
95
70
  return roles unless assignable_roles_present?(resource)
96
71
 
97
- current_user ||= (EffectiveRoles.current_user || (EffectiveLogging.current_user if defined?(EffectiveLogging)))
98
-
99
72
  if current_user && !current_user.respond_to?(:is_role_restricted?)
100
- raise('expected current_user to respond to is_role_restricted?')
73
+ raise('expected current_user to respond to is_role_restricted?')
101
74
  end
102
75
 
103
76
  if !resource.respond_to?(:is_role_restricted?)
104
- raise('expected current_user to respond to is_role_restricted?')
77
+ raise('expected current_user to respond to is_role_restricted?')
105
78
  end
106
79
 
107
80
  assigned_roles = if assignable_roles.kind_of?(Hash)
@@ -138,13 +111,11 @@ module EffectiveRoles
138
111
  end
139
112
 
140
113
  def self.assignable_roles_present?(resource)
141
- return false if assignable_roles.nil?
114
+ return false unless assignable_roles.present?
142
115
 
143
- raise 'EffectiveRoles config.assignable_roles_for must be a Hash, Array or nil' unless [Hash, Array].include?(assignable_roles.class)
116
+ raise 'EffectiveRoles config.assignable_roles_for must be a Hash or Array' unless [Hash, Array].include?(assignable_roles.class)
144
117
  raise('expected resource to respond to is_role_restricted?') unless resource.respond_to?(:is_role_restricted?)
145
118
 
146
- return assignable_roles.present? if assignable_roles.kind_of?(Array)
147
-
148
119
  if assignable_roles.kind_of?(Array)
149
120
  assignable_roles
150
121
  elsif assignable_roles.key?(resource.class.to_s)
@@ -154,113 +125,14 @@ module EffectiveRoles
154
125
  end.present?
155
126
  end
156
127
 
157
- # This is used by the effective_roles_summary_table helper method
158
- def self.authorization_level(controller, role, resource)
159
- return :unknown unless (authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol))
160
- return :unknown unless (controller.current_user rescue nil).respond_to?(:roles=)
161
-
162
- # Store the current ability (cancan support) and roles
163
- current_ability = controller.instance_variable_get(:@current_ability)
164
- current_user = controller.instance_variable_get(:@current_user)
165
- current_user_roles = controller.current_user.roles
166
-
167
- # Set up the user, so the check is done with the desired permission level
168
- controller.instance_variable_set(:@current_ability, nil)
169
-
170
- level = nil
171
-
172
- case role
173
- when :signed_in
174
- controller.current_user.roles = []
175
- when :public
176
- controller.instance_variable_set(:@current_user, nil)
177
-
178
- if defined?(EffectiveLogging)
179
- EffectiveLogging.supressed { (controller.request.env['warden'].set_user(false) rescue nil) }
180
- else
181
- (controller.request.env['warden'].set_user(false) rescue nil)
182
- end
183
- else
184
- controller.current_user.roles = [role]
185
- end
186
-
187
- # Find the actual authorization level
188
- level = _authorization_level(controller, role, resource, authorization_method)
189
-
190
- # Restore the existing current_user stuff
191
- if role == :public
192
- ActiveRecord::Base.transaction do
193
- if defined?(EffectiveLogging)
194
- EffectiveLogging.supressed { (controller.request.env['warden'].set_user(current_user) rescue nil) }
195
- else
196
- (controller.request.env['warden'].set_user(current_user) rescue nil)
197
- end
198
-
199
- raise ActiveRecord::Rollback
200
- end
201
- end
202
-
203
- controller.instance_variable_set(:@current_ability, current_ability)
204
- controller.instance_variable_set(:@current_user, current_user)
205
- controller.current_user.roles = current_user_roles
206
-
207
- level
208
- end
209
-
210
128
  private
211
129
 
212
130
  def self.role_description(role, obj = nil)
213
131
  raise 'EffectiveRoles config.role_descriptions must be a Hash' unless role_descriptions.kind_of?(Hash)
214
- (role_descriptions[obj.try(:class).to_s] || {})[role] || role_descriptions[role] || ''
215
- end
216
-
217
- def self._authorization_level(controller, role, resource, auth_method)
218
- resource = (resource.new() rescue resource) if resource.kind_of?(ActiveRecord::Base)
219
-
220
- # Custom actions
221
- if resource.kind_of?(Hash)
222
- resource.each do |key, value|
223
- return (controller.instance_exec(controller, key, value, &auth_method) rescue false) ? :yes : :no
224
- end
225
- end
226
-
227
- # Check for Manage
228
- return :manage if (
229
- (controller.instance_exec(controller, :create, resource, &auth_method) rescue false) &&
230
- (controller.instance_exec(controller, :update, resource, &auth_method) rescue false) &&
231
- (controller.instance_exec(controller, :show, resource, &auth_method) rescue false) &&
232
- (controller.instance_exec(controller, :destroy, resource, &auth_method) rescue false)
233
- )
234
-
235
- # Check for Update
236
- return :update if (controller.instance_exec(controller, :update, resource, &auth_method) rescue false)
237
-
238
- # Check for Update Own
239
- if resource.respond_to?('user=')
240
- resource.user = controller.current_user
241
- return :update_own if (controller.instance_exec(controller, :update, resource, &auth_method) rescue false)
242
- resource.user = nil
243
- elsif resource.respond_to?('user_id=')
244
- resource.user_id = controller.current_user.id
245
- return :update_own if (controller.instance_exec(controller, :update, resource, &auth_method) rescue false)
246
- resource.user_id = nil
247
- elsif resource.kind_of?(User)
248
- return :update_own if (controller.instance_exec(controller, :update, controller.current_user, &auth_method) rescue false)
249
- end
250
-
251
- # Check for Create
252
- return :create if (controller.instance_exec(controller, :create, resource, &auth_method) rescue false)
253
-
254
- # Check for Show
255
- return :show if (controller.instance_exec(controller, :show, resource, &auth_method) rescue false)
256
-
257
- # Check for Index
258
- return :index if (controller.instance_exec(controller, :index, resource, &auth_method) rescue false)
259
-
260
- # Check for Destroy
261
- return :destroy if (controller.instance_exec(controller, :destroy, resource, &auth_method) rescue false)
262
132
 
263
- :none
133
+ description = role_descriptions.dig(obj.class.to_s, role) if obj.present?
134
+ description ||= role_descriptions[role]
135
+ description || ''
264
136
  end
265
137
 
266
138
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_roles
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-13 00:00:00.000000000 Z
11
+ date: 2021-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: effective_resources
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Assign multiple roles to any User or other ActiveRecord object. Select
28
42
  only the appropriate objects based on intelligent, chainable ActiveRecord::Relation
29
43
  finder methods.
@@ -38,7 +52,6 @@ files:
38
52
  - app/controllers/admin/roles_controller.rb
39
53
  - app/helpers/effective_roles_helper.rb
40
54
  - app/models/concerns/acts_as_role_restricted.rb
41
- - app/models/effective/access_denied.rb
42
55
  - app/views/admin/roles/index.html.haml
43
56
  - app/views/effective/roles/_summary.html.haml
44
57
  - app/views/effective/roles/_summary_table.html.haml
@@ -46,7 +59,6 @@ files:
46
59
  - config/routes.rb
47
60
  - lib/effective_roles.rb
48
61
  - lib/effective_roles/engine.rb
49
- - lib/effective_roles/set_current_user.rb
50
62
  - lib/effective_roles/version.rb
51
63
  - lib/generators/effective_roles/install_generator.rb
52
64
  homepage: https://github.com/code-and-effect/effective_roles
@@ -1,17 +0,0 @@
1
- unless defined?(Effective::AccessDenied)
2
- module Effective
3
- class AccessDenied < StandardError
4
- attr_reader :action, :subject
5
-
6
- def initialize(message = nil, action = nil, subject = nil)
7
- @message = message
8
- @action = action
9
- @subject = subject
10
- end
11
-
12
- def to_s
13
- @message || I18n.t(:'unauthorized.default', :default => 'Access Denied')
14
- end
15
- end
16
- end
17
- end
@@ -1,15 +0,0 @@
1
- module EffectiveRoles
2
- module SetCurrentUser
3
- module ActionController
4
-
5
- # Add me to your ApplicationController
6
- # before_action :set_effective_roles_current_user
7
-
8
- def set_effective_roles_current_user
9
- EffectiveRoles.current_user = current_user
10
- end
11
-
12
- end
13
- end
14
- end
15
-