di-simple_auth 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 2
3
- :patch: 1
3
+ :patch: 2
4
4
  :major: 0
@@ -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
- - 1
9
- version: 0.2.1
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-09 00:00:00 +03:00
17
+ date: 2010-03-10 00:00:00 +03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency