petergate 1.1.3 → 1.1.4

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: 0513baf0efe509d8dc89970f477be3f1d8131c1f
4
- data.tar.gz: b47dbc9efc8e44d95820fe7643fbdde16d7b497e
3
+ metadata.gz: 7d882eeb3e09ea3404933ed107a6b1b477c13f1a
4
+ data.tar.gz: e1325d7e46ca598219f47593bd82ad8193399574
5
5
  SHA512:
6
- metadata.gz: 2c423bc6a4692b235c3df4c2c48ed60bd7d8e49e355dd82e12fafabe6959cee95709a26fb84a82f65be2b430db7f5220b3d6fe2e025e73ee8245478ace7f3953
7
- data.tar.gz: f389480b9c5a96c1751e13db841f01938561894be21909cafd27f831bab655616edc745d90831a81b4972d87e9a13e8366f5d6a78096d9c7224fcb5f3bafefbf
6
+ metadata.gz: 7ef493c0db45b0a446619ebc3624904ce3a54b801affc26a2ddfd08351f314bb65d520e63080abed1d7eb2914fc40b18efe62c78d537d4bb8febac3a2e452ee0
7
+ data.tar.gz: 0ffe29f07c7e46231033d4b8ab40967fc80866c5cfc0ffc898a6f5f30cf5fb1165c6d1e6995709b6b3e3394db72021289366da5223a77861475c355161e3c792
data/lib/petergate.rb CHANGED
@@ -47,18 +47,13 @@ module Petergate
47
47
 
48
48
  def self.included(base)
49
49
  base.extend(ClassMethods)
50
- base.helper_method :logged_in?
50
+ base.helper_method :logged_in?, :forbidden!
51
51
  base.before_filter do
52
52
  unless logged_in?(:admin)
53
53
  message= defined?(check_access) ? check_access : true
54
54
  if message.is_a?(String) || message == false
55
55
  if user_signed_in?
56
- respond_to do |format|
57
- format.any(:js, :json, :xml) { render nothing: true, status: :forbidden }
58
- format.html do
59
- redirect_to (request.referrer || after_sign_in_path_for(current_user)), :notice => message || "Permission Denied"
60
- end
61
- end
56
+ forbidden! message
62
57
  else
63
58
  authenticate_user!
64
59
  end
@@ -104,6 +99,14 @@ module Petergate
104
99
  current_user && (roles & current_user.roles).any?
105
100
  end
106
101
 
102
+ def forbidden!(msg = nil)
103
+ respond_to do |format|
104
+ format.any(:js, :json, :xml) { render nothing: true, status: :forbidden }
105
+ format.html do
106
+ redirect_to (request.referrer || after_sign_in_path_for(current_user)), notice: msg || 'Permission Denied'
107
+ end
108
+ end
109
+ end
107
110
  end
108
111
 
109
112
  module UserMethods
@@ -1,3 +1,3 @@
1
1
  module Petergate
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4"
3
3
  end
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.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Isaac Sloan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler