di-simple_auth 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/simple_auth/authentication.rb +20 -2
- metadata +3 -3
data/VERSION.yml
CHANGED
@@ -29,6 +29,10 @@ module SimpleAuth
|
|
29
29
|
def current_permission(invoice)
|
30
30
|
@_current_permission ||= permission_from_token(invoice)
|
31
31
|
end
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
32
36
|
|
33
37
|
# Set the current user
|
34
38
|
#
|
@@ -41,9 +45,23 @@ module SimpleAuth
|
|
41
45
|
#
|
42
46
|
# @return [true, false]
|
43
47
|
def signed_in?
|
44
|
-
! current_user.nil?
|
48
|
+
! current_user.nil? ||
|
45
49
|
end
|
46
50
|
|
51
|
+
#Is exist permission and invoice
|
52
|
+
#
|
53
|
+
# @return [true,false]
|
54
|
+
def permission_exist?
|
55
|
+
if params[:token] && _permission_token = params[:token][12..-1]
|
56
|
+
_invoice_token = params[:token][0..11]
|
57
|
+
_invoice = Invoice.find_by_token(_invoice_token)
|
58
|
+
_permission = Permission.find_by_token(_permission_token)
|
59
|
+
_invoice && _permission
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
47
65
|
# Is the current user signed out?
|
48
66
|
#
|
49
67
|
# @return [true, false]
|
@@ -56,7 +74,7 @@ module SimpleAuth
|
|
56
74
|
# @example
|
57
75
|
# before_filter :authenticate
|
58
76
|
def authenticate
|
59
|
-
deny_access
|
77
|
+
deny_access if (!signed_in? && !permission_exist?)
|
60
78
|
end
|
61
79
|
|
62
80
|
# Sign user in to cookie.
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 2
|
9
|
+
version: 0.3.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-15 00:00:00 +03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|