petergate 1.2.6 → 1.3.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
  SHA1:
3
- metadata.gz: 42a4adfd54cbc87882bbdd7a2814a730f00c114d
4
- data.tar.gz: 4d808df27318ddb05729d71f448191f031242386
3
+ metadata.gz: 8be82833c7259e85ee80f35a935c7762a80bb9d2
4
+ data.tar.gz: f45cce812bbdc12d63a317a1759e5fd013c73add
5
5
  SHA512:
6
- metadata.gz: 39b149a2b6f61103fa894639e8bd3b68ac79a29fe910694c90f849bc3d45f38c62503c6aa14c95b7715bb4e95c85fe5af26b1de8cdde8446f429312e807317fb
7
- data.tar.gz: dcfa2863d772ade79d23f9d11dc21122bac89d1b97373e3d86032d67a466674643ef7906c7745624396a78e1df2b2baad157e2256144091842b294f0b3b7801b
6
+ metadata.gz: b18da7bf7fc915bc1b67e3f7602c58a6e45cddfc3b1f53753036839f08ca3ec9546ead0ad5166c3c0a02f442df98dabd57f72daa1930a552a196db046871736f
7
+ data.tar.gz: ad2529c9ed5c8b84b50874fcd2e0d2d3b8de58d7675239fd1e693d92e463f97516958b63cdaf1f55ad63e552f3b83ad79fca18a3e5567076b041d40f57f1284c
@@ -27,11 +27,16 @@ module Petergate
27
27
 
28
28
  instance_eval do
29
29
  @_controller_rules = rules
30
+ @_controller_message = rules.delete(:message)
30
31
 
31
32
  def controller_rules
32
33
  @_controller_rules
33
34
  end
34
35
 
36
+ def controller_message
37
+ @_controller_message
38
+ end
39
+
35
40
  def inherited(subclass)
36
41
  subclass.instance_variable_set("@_controller_rules", instance_variable_get("@_controller_rules"))
37
42
  end
@@ -53,7 +58,7 @@ module Petergate
53
58
  base.before_filter do
54
59
  unless logged_in?(:admin)
55
60
  message= defined?(check_access) ? check_access : true
56
- if message.is_a?(String) || message.nil?
61
+ if message == false || message.is_a?(String)
57
62
  if user_signed_in?
58
63
  forbidden! message
59
64
  else
@@ -84,13 +89,12 @@ module Petergate
84
89
  end
85
90
 
86
91
  def permissions(rules = {all: [:index, :show], customer: [], wiring: []})
87
- message = rules.delete(:message)
88
92
  rules = parse_permission_rules(rules)
89
93
  allowances = [rules[:all]]
90
94
  current_user.roles.each do |role|
91
95
  allowances << rules[role]
92
96
  end if logged_in?(:user)
93
- allowances.flatten.compact.include?(params[:action].to_sym) || message
97
+ allowances.flatten.compact.include?(params[:action].to_sym)
94
98
  end
95
99
 
96
100
  def logged_in?(*roles)
@@ -102,7 +106,7 @@ module Petergate
102
106
  format.any(:js, :json, :xml) { render nothing: true, status: :forbidden }
103
107
  format.html do
104
108
  destination = current_user.present? ? request.referrer || after_sign_in_path_for(current_user) : root_path
105
- redirect_to destination, notice: (msg || 'Permission Denied')
109
+ redirect_to destination, notice: (msg || self.class.controller_message || 'Permission Denied')
106
110
  end
107
111
  end
108
112
  end
@@ -1,3 +1,3 @@
1
1
  module Petergate
2
- VERSION = "1.2.6"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: petergate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Isaac Sloan