simplest_auth 0.2.6 → 0.2.9
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.
@@ -43,10 +43,10 @@ module SimplestAuth
|
|
43
43
|
|
44
44
|
def current_user
|
45
45
|
@current_user ||= begin
|
46
|
-
if user_class.respond_to?(:
|
47
|
-
user_class.
|
46
|
+
if user_class.respond_to?(:get)
|
47
|
+
user_class.get(current_user_id)
|
48
48
|
else
|
49
|
-
user_class.
|
49
|
+
user_class.find(current_user_id)
|
50
50
|
end
|
51
51
|
end || clear_session
|
52
52
|
end
|
data/lib/simplest_auth/model.rb
CHANGED
@@ -75,7 +75,7 @@ module SimplestAuth
|
|
75
75
|
RecordNotFound = Class.new(StandardError) unless defined?(RecordNotFound)
|
76
76
|
|
77
77
|
def authentic?(password)
|
78
|
-
Password.new(self.crypted_password) == password
|
78
|
+
Password.new(self.crypted_password) == password rescue false
|
79
79
|
end
|
80
80
|
|
81
81
|
private
|
@@ -89,8 +89,18 @@ class ControllerTest < Test::Unit::TestCase
|
|
89
89
|
stubs(:current_user_id).returns(nil)
|
90
90
|
assert_equal false, logged_in?
|
91
91
|
end
|
92
|
-
|
93
|
-
should "
|
92
|
+
|
93
|
+
should "#get the current user" do
|
94
|
+
user_stub = stub
|
95
|
+
user_stub.stubs(:get).with(1).returns("user")
|
96
|
+
|
97
|
+
stubs(:current_user_id).returns(1)
|
98
|
+
stubs(:user_class).returns(user_stub)
|
99
|
+
|
100
|
+
assert_equal "user", current_user
|
101
|
+
end
|
102
|
+
|
103
|
+
should "#find the current user when #get fails" do
|
94
104
|
user_stub = stub()
|
95
105
|
user_stub.stubs(:find).with(1).returns("user")
|
96
106
|
|
@@ -113,14 +123,6 @@ class ControllerTest < Test::Unit::TestCase
|
|
113
123
|
clear_session
|
114
124
|
end
|
115
125
|
|
116
|
-
should "find with first when class doesn't respond to find" do
|
117
|
-
User.expects(:respond_to?).with(:find).returns(false)
|
118
|
-
User.stubs(:first).with(:id => '1').returns("user")
|
119
|
-
stubs(:current_user_id).with().returns('1')
|
120
|
-
|
121
|
-
assert_equal "user", current_user
|
122
|
-
end
|
123
|
-
|
124
126
|
should "allow assigning to the current user" do
|
125
127
|
stubs(:session).returns({})
|
126
128
|
user = mock(:id => 1)
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplest_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 9
|
9
|
+
version: 0.2.9
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Tony Pitale
|
@@ -9,19 +14,23 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-07-05 00:00:00 -04:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: bcrypt-ruby
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ~>
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 1
|
30
|
+
- 1
|
23
31
|
version: 2.1.1
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
description:
|
26
35
|
email: tony.pitale@viget.com
|
27
36
|
executables: []
|
@@ -54,18 +63,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
54
63
|
requirements:
|
55
64
|
- - ">="
|
56
65
|
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
57
68
|
version: "0"
|
58
|
-
version:
|
59
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
70
|
requirements:
|
61
71
|
- - ">="
|
62
72
|
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 0
|
63
75
|
version: "0"
|
64
|
-
version:
|
65
76
|
requirements: []
|
66
77
|
|
67
78
|
rubyforge_project:
|
68
|
-
rubygems_version: 1.3.
|
79
|
+
rubygems_version: 1.3.6
|
69
80
|
signing_key:
|
70
81
|
specification_version: 3
|
71
82
|
summary: Simple implementation of authentication for Rails
|