cul_omniauth 0.3.1 → 0.3.2
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a955dd2cc9270430db92c8b03bec61389433d945
|
4
|
+
data.tar.gz: 631f84ab0137bb08cba79631be673df44cb57f06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7acc0a7d9c0fac857d28e5a9ef63894502dcbf9e8ade213cc387f254c7d31c75b3c2ed7fe65be36f3e46c2203eae239a5429b2b1e35770c0fffc94465c7bb050
|
7
|
+
data.tar.gz: 11feb2c0e5c9065a59a370f73134cf08400ee213975a36a9a1183c65095b7498d8190f18014ec428debb7f5fadc955ff87e6effcb33eba1dd490717bb44949f8
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module Cul::Omniauth::Abilities
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
EMPTY = [].freeze
|
4
|
-
def initialize(user, opts={})
|
4
|
+
def initialize(user=nil, opts={})
|
5
5
|
@user = user || User.new
|
6
6
|
if user
|
7
7
|
role_permissions = self.class.config.select {|role,config| user.role? role }
|
8
|
+
opts = {user_id: user.login}.merge(opts)
|
8
9
|
else
|
9
10
|
role_permissions = {:'*' => self.class.config.fetch(:*,EMPTY)}
|
10
11
|
end
|
@@ -16,17 +17,26 @@ module Cul::Omniauth::Abilities
|
|
16
17
|
can action, :all
|
17
18
|
else
|
18
19
|
can action, Cul::Omniauth::AbilityProxy do |proxy|
|
19
|
-
|
20
|
-
|
20
|
+
combine_with = conditions.fetch(:combine_with,:and).to_sym
|
21
|
+
r = (combine_with == :and)
|
22
|
+
if !!proxy
|
21
23
|
conditions.fetch(:if,EMPTY).each do |property, comparisons|
|
22
24
|
p = value_for_property(proxy, property, opts)
|
23
|
-
|
24
|
-
|
25
|
+
if combine_with == :and
|
26
|
+
r &= !!p
|
27
|
+
r &= comparisons.detect {|c,v| Comparisons.send(c, p, v)}
|
28
|
+
elsif p
|
29
|
+
r ||= comparisons.detect {|c,v| Comparisons.send(c, p, v)}
|
30
|
+
end
|
25
31
|
end
|
26
32
|
conditions.fetch(:unless,EMPTY).each do |property, comparisons|
|
27
33
|
p = value_for_property(proxy, property, opts)
|
28
34
|
if p
|
29
|
-
|
35
|
+
if combine_with == :and
|
36
|
+
r &= !comparisons.detect {|c,v| Comparisons.send(c, p, v)}
|
37
|
+
else
|
38
|
+
r ||= !comparisons.detect {|c,v| Comparisons.send(c, p, v)}
|
39
|
+
end
|
30
40
|
end
|
31
41
|
end
|
32
42
|
end
|
@@ -41,7 +51,7 @@ module Cul::Omniauth::Abilities
|
|
41
51
|
if proxy.respond_to? property_handle.to_sym
|
42
52
|
property = proxy.send property_handle
|
43
53
|
end
|
44
|
-
property = opts.fetch(property_handle,EMPTY) if property.blank?
|
54
|
+
property = opts.fetch(property_handle,EMPTY) if property.blank? || property.empty?
|
45
55
|
property
|
46
56
|
end
|
47
57
|
module Comparisons
|
@@ -49,10 +59,11 @@ module Cul::Omniauth::Abilities
|
|
49
59
|
context.include? value
|
50
60
|
end
|
51
61
|
def self.eql?(context, value)
|
62
|
+
puts "eql? #{context.inspect} #{value}"
|
52
63
|
context.eql? value
|
53
64
|
end
|
54
65
|
def self.in?(context, value)
|
55
|
-
puts "#{context.inspect} #{value}"
|
66
|
+
puts "in? #{context.inspect} #{value}"
|
56
67
|
(Array(value) & Array(context)).size > 0
|
57
68
|
end
|
58
69
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
module Cul::Omniauth
|
2
2
|
class AbilityProxy
|
3
|
-
attr_accessor :mime_type, :context, :content_models, :publisher, :remote_ip
|
3
|
+
attr_accessor :mime_type, :context, :content_models, :publisher, :remote_ip, :user_id, :user_roles
|
4
4
|
def initialize(opts = {})
|
5
5
|
self.mime_type = opts[:mime_type]
|
6
6
|
self.context = opts[:context]
|
7
7
|
self.content_models = opts[:content_models] || []
|
8
8
|
self.publisher = opts[:publisher] || []
|
9
9
|
self.remote_ip = opts[:remote_ip] || []
|
10
|
+
self.user_id = opts[:user_id] || []
|
11
|
+
self.user_roles = opts[:user_roles] || []
|
10
12
|
end
|
11
13
|
def to_h
|
12
14
|
return {
|
data/lib/cul/omniauth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cul_omniauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- barmintor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|