petergate 1.2.1 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/petergate/action_controller/base.rb +10 -9
- data/lib/petergate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8195676a80d896b9c03096811dfe1a2f0ba103d9
|
4
|
+
data.tar.gz: 22dde73f57a394c67bc6b44f83c930b44a56203c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c37088d9935b4baf5428babd3621bfbe185bc34103795a13c1616f3aac6228c8013f11dd938624dcf7d08c7848be52be529e0653a7c38dae911c180a0bf5cb5
|
7
|
+
data.tar.gz: 6c44f18ade5b9101605bd8f2ab53a2505718aa23a10f2d0a27f7fc7aef8136b75992c6bddbde771d31efbd50681f405beddca98df6267c9ac298d61c31e96e24
|
@@ -53,7 +53,7 @@ module Petergate
|
|
53
53
|
base.before_filter do
|
54
54
|
unless logged_in?(:admin)
|
55
55
|
message= defined?(check_access) ? check_access : true
|
56
|
-
if message.is_a?(String) || message
|
56
|
+
if message.is_a?(String) || message.nil?
|
57
57
|
if user_signed_in?
|
58
58
|
forbidden! message
|
59
59
|
else
|
@@ -71,25 +71,26 @@ module Petergate
|
|
71
71
|
v == :all ? self.class.all_actions : raise("No action for: #{v}")
|
72
72
|
when "Hash"
|
73
73
|
v[:except].present? ? self.class.except_actions(v[:except]) : raise("Invalid values for except: #{v.values}")
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
when "Array"
|
75
|
+
v
|
76
|
+
else
|
77
|
+
raise("No action for: #{v}")
|
78
|
+
end
|
79
79
|
|
80
80
|
h.merge({k => special_values})
|
81
81
|
end
|
82
82
|
# Allows Array's of keys for he same hash.
|
83
|
-
rules.inject({}){|h, (k, v)| k.class == Array ? h.merge(Hash[k.map{|kk| [kk, v]}]) : h.merge(k => v) }
|
83
|
+
rules = rules.inject({}){|h, (k, v)| k.class == Array ? h.merge(Hash[k.map{|kk| [kk, v]}]) : h.merge(k => v) }
|
84
84
|
end
|
85
85
|
|
86
86
|
def permissions(rules = {all: [:index, :show], customer: [], wiring: []})
|
87
|
+
message = rules.delete(:message)
|
87
88
|
rules = parse_permission_rules(rules)
|
88
89
|
allowances = [rules[:all]]
|
89
90
|
current_user.roles.each do |role|
|
90
91
|
allowances << rules[role]
|
91
92
|
end if logged_in?(:user)
|
92
|
-
allowances.flatten.compact.include?(params[:action].to_sym)
|
93
|
+
allowances.flatten.compact.include?(params[:action].to_sym) || message
|
93
94
|
end
|
94
95
|
|
95
96
|
def logged_in?(*roles)
|
@@ -101,7 +102,7 @@ module Petergate
|
|
101
102
|
format.any(:js, :json, :xml) { render nothing: true, status: :forbidden }
|
102
103
|
format.html do
|
103
104
|
destination = current_user.present? ? request.referrer || after_sign_in_path_for(current_user) : root_path
|
104
|
-
redirect_to destination, notice: msg || 'Permission Denied'
|
105
|
+
redirect_to destination, notice: (msg || 'Permission Denied')
|
105
106
|
end
|
106
107
|
end
|
107
108
|
end
|
data/lib/petergate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: petergate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Sloan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01
|
11
|
+
date: 2016-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|