rabarber 6.0.1 → 6.0.3
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 +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +2 -2
- data/lib/rabarber/core/roleable.rb +2 -4
- data/lib/rabarber/models/role.rb +3 -1
- data/lib/rabarber/railtie.rb +6 -19
- data/lib/rabarber/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c7481864a3dc409501c34dc66d1f7bfe3399118285fb99cbc6979b17c1b75ff3
|
|
4
|
+
data.tar.gz: ea2c8e12a4a28be3166d4fb60db78e5c5857e838697a5b2308db2486e81d92ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 239a2ba8dc2541688ab09fdbf143d9246e6a725d5ac8adebd253c2ef5d2a7935a4b51d4dffadfb6f490cb6871955b1832c6f24188bfe389abbf22287627652d8
|
|
7
|
+
data.tar.gz: bdf91f9803ec0fd770a7bdb8b0267e63566078a7496b736b0cfdc8a2b7084c73be0836148e0d89e887f8753338fc9efa3a15213f3fa839229b041497349f8908
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## v6.0.3
|
|
2
|
+
|
|
3
|
+
### Bugs:
|
|
4
|
+
|
|
5
|
+
- Fixed `Rabarber.all_roles` raising `Rabarber::NotFoundError` when a role's context is a class that is not an ActiveRecord model
|
|
6
|
+
|
|
7
|
+
## v6.0.2
|
|
8
|
+
|
|
9
|
+
### Bugs:
|
|
10
|
+
|
|
11
|
+
- Fixed Rails commands failing when the configured user model class does not exist yet
|
|
12
|
+
|
|
1
13
|
## v6.0.1
|
|
2
14
|
|
|
3
15
|
### Bugs:
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Rabarber: Simple
|
|
1
|
+
# Rabarber: Simple Authorization for Rails
|
|
2
2
|
|
|
3
3
|
[](http://badge.fury.io/rb/rabarber)
|
|
4
4
|
[](https://rubygems.org/gems/rabarber)
|
|
@@ -409,7 +409,7 @@ end
|
|
|
409
409
|
|
|
410
410
|
When a context object is deleted from your database, its associated roles become orphaned and ignored by Rabarber.
|
|
411
411
|
|
|
412
|
-
|
|
412
|
+
Ideally, the application should be designed so that this doesn't happen: whenever a context object is deleted, its roles are revoked and deleted as part of the same operation. However, if that wasn't done, you can clean up the orphaned roles as a fallback:
|
|
413
413
|
|
|
414
414
|
```rb
|
|
415
415
|
Rabarber.prune
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
module Rabarber
|
|
4
4
|
module Core
|
|
5
5
|
module Roleable
|
|
6
|
+
private
|
|
7
|
+
|
|
6
8
|
def roleable
|
|
7
9
|
current_roleable = send(Rabarber::Configuration.current_user_method)
|
|
8
10
|
|
|
@@ -15,10 +17,6 @@ module Rabarber
|
|
|
15
17
|
|
|
16
18
|
current_roleable
|
|
17
19
|
end
|
|
18
|
-
|
|
19
|
-
def roleable_roles(context: nil)
|
|
20
|
-
roleable.roles(context:)
|
|
21
|
-
end
|
|
22
20
|
end
|
|
23
21
|
end
|
|
24
22
|
end
|
data/lib/rabarber/models/role.rb
CHANGED
|
@@ -12,7 +12,9 @@ module Rabarber
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def list_all
|
|
15
|
-
|
|
15
|
+
roles = where(context_id: nil).to_a + where.not(context_id: nil).includes(:context).to_a
|
|
16
|
+
|
|
17
|
+
roles.each_with_object({}) do |role, hash|
|
|
16
18
|
(hash[role.context] ||= []) << role.name.to_sym
|
|
17
19
|
rescue ActiveRecord::RecordNotFound
|
|
18
20
|
next
|
data/lib/rabarber/railtie.rb
CHANGED
|
@@ -4,31 +4,18 @@ require "rails/railtie"
|
|
|
4
4
|
|
|
5
5
|
module Rabarber
|
|
6
6
|
class Railtie < Rails::Railtie
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
rescue ActiveRecord::NoDatabaseError, ActiveRecord::ConnectionNotEstablished
|
|
14
|
-
false
|
|
7
|
+
initializer "rabarber.include_roleable" do
|
|
8
|
+
Rails.autoloaders.each do |autoloader|
|
|
9
|
+
autoloader.on_load do |cpath, klass, _abspath|
|
|
10
|
+
klass.include Rabarber::Roleable if cpath == Rabarber::Configuration.user_model_name
|
|
11
|
+
end
|
|
12
|
+
end
|
|
15
13
|
end
|
|
16
14
|
|
|
17
15
|
initializer "rabarber.to_prepare" do |app|
|
|
18
16
|
app.config.to_prepare do
|
|
19
|
-
if Rabarber::Railtie.server_running? && Rabarber::Railtie.table_exists?
|
|
20
|
-
Rabarber::Role.where.not(context_type: nil).distinct.pluck(:context_type).each do |context_class|
|
|
21
|
-
context_class.constantize
|
|
22
|
-
rescue NameError => e
|
|
23
|
-
raise Rabarber::Error, "Context not found: class `#{e.name}` may have been renamed or deleted"
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
17
|
Rabarber::Core::Permissions.reset! unless app.config.eager_load
|
|
28
18
|
|
|
29
|
-
user_model = Rabarber::Configuration.user_model
|
|
30
|
-
user_model.include Rabarber::Roleable unless user_model < Rabarber::Roleable
|
|
31
|
-
|
|
32
19
|
Rabarber::Role.send(:remove_const, :HABTM_Roleables) if Rabarber::Role.const_defined?(:HABTM_Roleables, false)
|
|
33
20
|
Rabarber::Role.has_and_belongs_to_many :roleables, class_name: Rabarber::Configuration.user_model_name,
|
|
34
21
|
association_foreign_key: "roleable_id",
|
data/lib/rabarber/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rabarber
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.0.
|
|
4
|
+
version: 6.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- enjaku4
|
|
8
8
|
- trafium
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
98
98
|
- !ruby/object:Gem::Version
|
|
99
99
|
version: '0'
|
|
100
100
|
requirements: []
|
|
101
|
-
rubygems_version: 4.0.
|
|
101
|
+
rubygems_version: 4.0.16
|
|
102
102
|
specification_version: 4
|
|
103
103
|
summary: Simple role-based authorization library for Ruby on Rails
|
|
104
104
|
test_files: []
|