di-simple_auth 0.2.1 → 0.2.2
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.
- data/VERSION.yml +1 -1
- data/lib/simple_auth/authentication.rb +13 -0
- metadata +3 -3
data/VERSION.yml
CHANGED
@@ -24,6 +24,11 @@ module SimpleAuth
|
|
24
24
|
def current_user
|
25
25
|
@_current_user ||= user_from_cookie
|
26
26
|
end
|
27
|
+
|
28
|
+
|
29
|
+
def current_permission(invoice)
|
30
|
+
@_current_permission ||= permission_from_token(invoice)
|
31
|
+
end
|
27
32
|
|
28
33
|
# Set the current user
|
29
34
|
#
|
@@ -97,6 +102,14 @@ module SimpleAuth
|
|
97
102
|
::User.find_by_remember_token(token)
|
98
103
|
end
|
99
104
|
end
|
105
|
+
|
106
|
+
def permission_from_token(invoice)
|
107
|
+
if current_user
|
108
|
+
current_user.permissions(invoice).max(&:index)
|
109
|
+
elsif params[:token][10..-1]
|
110
|
+
::Permission.find_by_token(token)
|
111
|
+
end
|
112
|
+
end
|
100
113
|
|
101
114
|
def store_location
|
102
115
|
if request.get?
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 2
|
9
|
+
version: 0.2.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Dieinzige
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-10 00:00:00 +03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|