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 +4 -4
- data/lib/petergate.rb +10 -7
- 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: 7d882eeb3e09ea3404933ed107a6b1b477c13f1a
|
4
|
+
data.tar.gz: e1325d7e46ca598219f47593bd82ad8193399574
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
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.1.
|
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-
|
11
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|