porteiro 0.0.2 → 0.0.3
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 +4 -4
- data/lib/porteiro.rb +6 -1
- data/lib/porteiro/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc1abca76118ff41f97227c06ca84665ca56122a
|
4
|
+
data.tar.gz: 25098d250e680c167c5366e4dd0009699db1cde4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e549c7fe34b7a86fcd4676e0a698add91d0ed0cfaf3683e584bacc73e52f95b6f37fbe6930e51f33f3d6b9d061aef3500a09134b04b8fbe392d690dde529385
|
7
|
+
data.tar.gz: 12bd5b44d549b2349b4a43201e9c98524ddcc8149040d0cc9a23ab6495af9d1e6e83d39c11b8cb1e2e518744f77400906e085debb1b89cff8adb09ce231b1d15
|
data/lib/porteiro.rb
CHANGED
@@ -9,7 +9,7 @@ module Porteiro
|
|
9
9
|
|
10
10
|
class NotAuthorizedError < StandardError;end
|
11
11
|
class PolicyUndefinedError < StandardError;end
|
12
|
-
|
12
|
+
class AuthorizationNotPerformedError < StandardError;end
|
13
13
|
|
14
14
|
class << self
|
15
15
|
|
@@ -40,11 +40,16 @@ module Porteiro
|
|
40
40
|
##
|
41
41
|
|
42
42
|
def authorize_user_access!
|
43
|
+
@_policy_authorized = true
|
43
44
|
policy_obj = policy
|
44
45
|
controller_action = policy_obj.params.fetch(:action)
|
45
46
|
policy_obj.send("#{controller_action}?") ? true : (raise NotAuthorizedError, "You aren't permitted to access this resource")
|
46
47
|
end
|
47
48
|
|
49
|
+
def verify_authorized
|
50
|
+
raise AuthorizationNotPerformedError unless @_policy_authorized
|
51
|
+
end
|
52
|
+
|
48
53
|
def policy
|
49
54
|
@policy || Porteiro.policy(porteiro_user, params)
|
50
55
|
end
|
data/lib/porteiro/version.rb
CHANGED