authpwn_rails 0.5.0 → 0.5.1
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 +1 -1
- data/authpwn_rails.gemspec +10 -10
- data/lib/authpwn_rails/session.rb +5 -5
- data/lib/authpwn_rails/user_model.rb +8 -6
- data/test/cookie_controller_test.rb +2 -2
- data/test/user_test.rb +2 -2
- metadata +15 -9
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.5.
|
|
1
|
+
0.5.1
|
data/authpwn_rails.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{authpwn_rails}
|
|
8
|
-
s.version = "0.5.
|
|
8
|
+
s.version = "0.5.1"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Victor Costan"]
|
|
12
|
-
s.date = %q{2010-
|
|
12
|
+
s.date = %q{2010-10-06}
|
|
13
13
|
s.description = %q{Works with Facebook.}
|
|
14
14
|
s.email = %q{victor@costan.us}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -63,17 +63,17 @@ Gem::Specification.new do |s|
|
|
|
63
63
|
s.rubygems_version = %q{1.3.7}
|
|
64
64
|
s.summary = %q{User authentication for Rails 3 applications.}
|
|
65
65
|
s.test_files = [
|
|
66
|
-
"test/
|
|
66
|
+
"test/facebook_token_test.rb",
|
|
67
|
+
"test/session_controller_api_test.rb",
|
|
68
|
+
"test/user_test.rb",
|
|
69
|
+
"test/cookie_controller_test.rb",
|
|
70
|
+
"test/test_helper.rb",
|
|
67
71
|
"test/facebook_controller_test.rb",
|
|
68
|
-
"test/facebook_token_test.rb",
|
|
69
72
|
"test/helpers/application_controller.rb",
|
|
70
|
-
"test/helpers/db_setup.rb",
|
|
71
|
-
"test/helpers/fbgraph.rb",
|
|
72
73
|
"test/helpers/routes.rb",
|
|
73
|
-
"test/helpers/
|
|
74
|
-
"test/
|
|
75
|
-
"test/
|
|
76
|
-
"test/user_test.rb"
|
|
74
|
+
"test/helpers/fbgraph.rb",
|
|
75
|
+
"test/helpers/db_setup.rb",
|
|
76
|
+
"test/helpers/view_helpers.rb"
|
|
77
77
|
]
|
|
78
78
|
|
|
79
79
|
if s.respond_to? :specification_version then
|
|
@@ -42,15 +42,15 @@ module ControllerInstanceMethods
|
|
|
42
42
|
def current_user=(user)
|
|
43
43
|
@current_user = user
|
|
44
44
|
if user
|
|
45
|
-
session[:
|
|
45
|
+
session[:current_user_pid] = user.to_param
|
|
46
46
|
else
|
|
47
|
-
session.delete :
|
|
47
|
+
session.delete :current_user_pid
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def authenticate_using_session
|
|
52
52
|
return true if current_user
|
|
53
|
-
user_param = session[:
|
|
53
|
+
user_param = session[:current_user_pid]
|
|
54
54
|
user = user_param && User.find_by_param(user_param)
|
|
55
55
|
self.current_user = user if user
|
|
56
56
|
end
|
|
@@ -118,12 +118,12 @@ ActionController::Base.send :include, ControllerMixin
|
|
|
118
118
|
class ActionController::TestCase
|
|
119
119
|
# Sets the authenticated user in the test session.
|
|
120
120
|
def set_session_current_user(user)
|
|
121
|
-
request.session[:
|
|
121
|
+
request.session[:current_user_pid] = user ? user.to_param : nil
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
# The authenticated user in the test session.
|
|
125
125
|
def session_current_user
|
|
126
|
-
return nil unless user_param = request.session[:
|
|
126
|
+
return nil unless user_param = request.session[:current_user_pid]
|
|
127
127
|
User.find_by_param user_param
|
|
128
128
|
end
|
|
129
129
|
end
|
|
@@ -45,17 +45,19 @@ end # module AuthpwnRails::UserModel::ModelClassMethods
|
|
|
45
45
|
|
|
46
46
|
# Included in the metaclass of models that call pwnauth_user_model.
|
|
47
47
|
module ModelMetaclassMethods
|
|
48
|
-
# Queries
|
|
48
|
+
# Queries the database using the value returned by User#to_param.
|
|
49
|
+
#
|
|
50
|
+
# Returns nil if no matching User exists.
|
|
49
51
|
def find_by_param(param)
|
|
50
|
-
|
|
52
|
+
where(:email => param).first
|
|
51
53
|
end
|
|
52
54
|
|
|
53
55
|
# The authenticated user or nil.
|
|
54
56
|
def find_by_email_and_password(email, password)
|
|
55
|
-
|
|
56
|
-
(
|
|
57
|
+
user = where(:email => email).first
|
|
58
|
+
(user && user.password_matches?(password)) ? user : nil
|
|
57
59
|
end
|
|
58
|
-
|
|
60
|
+
|
|
59
61
|
# Computes a password hash from a raw password and a salt.
|
|
60
62
|
def hash_password(password, salt)
|
|
61
63
|
Digest::SHA2.hexdigest(password + salt)
|
|
@@ -77,7 +79,7 @@ module ModelMetaclassMethods
|
|
|
77
79
|
# the case for a new visitor.
|
|
78
80
|
def for_facebook_token(access_token)
|
|
79
81
|
FacebookToken.for(access_token).user
|
|
80
|
-
end
|
|
82
|
+
end
|
|
81
83
|
end # module AuthpwnRails::UserModel::ModelMetaclassMethods
|
|
82
84
|
|
|
83
85
|
|
|
@@ -33,8 +33,8 @@ class CookieControllerTest < ActionController::TestCase
|
|
|
33
33
|
assert_equal "User: #{Fixtures.identify(:john)}", response.body
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
test "invalid
|
|
37
|
-
get :show, {}, :
|
|
36
|
+
test "invalid user_pid in session" do
|
|
37
|
+
get :show, {}, :current_user_pid => 'random@user.com'
|
|
38
38
|
assert_response :success
|
|
39
39
|
assert_nil assigns(:current_user)
|
|
40
40
|
end
|
data/test/user_test.rb
CHANGED
|
@@ -64,7 +64,7 @@ class UserTest < ActiveSupport::TestCase
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
test 'to_param' do
|
|
67
|
-
assert_equal @
|
|
67
|
+
assert_equal 'dvdjohn@mit.edu', @user.to_param
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
test 'password_matches?' do
|
|
@@ -73,7 +73,7 @@ class UserTest < ActiveSupport::TestCase
|
|
|
73
73
|
assert_equal false, @user.password_matches?('password'),
|
|
74
74
|
"Another user's password"
|
|
75
75
|
end
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
test 'find_by_param' do
|
|
78
78
|
assert_equal users(:john), User.find_by_param(users(:john).to_param)
|
|
79
79
|
assert_equal users(:jane), User.find_by_param(users(:jane).to_param)
|
metadata
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: authpwn_rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 9
|
|
4
5
|
prerelease: false
|
|
5
6
|
segments:
|
|
6
7
|
- 0
|
|
7
8
|
- 5
|
|
8
|
-
-
|
|
9
|
-
version: 0.5.
|
|
9
|
+
- 1
|
|
10
|
+
version: 0.5.1
|
|
10
11
|
platform: ruby
|
|
11
12
|
authors:
|
|
12
13
|
- Victor Costan
|
|
@@ -14,7 +15,7 @@ autorequire:
|
|
|
14
15
|
bindir: bin
|
|
15
16
|
cert_chain: []
|
|
16
17
|
|
|
17
|
-
date: 2010-
|
|
18
|
+
date: 2010-10-06 00:00:00 -04:00
|
|
18
19
|
default_executable:
|
|
19
20
|
dependencies:
|
|
20
21
|
- !ruby/object:Gem::Dependency
|
|
@@ -25,6 +26,7 @@ dependencies:
|
|
|
25
26
|
requirements:
|
|
26
27
|
- - ">="
|
|
27
28
|
- !ruby/object:Gem::Version
|
|
29
|
+
hash: 29
|
|
28
30
|
segments:
|
|
29
31
|
- 0
|
|
30
32
|
- 1
|
|
@@ -40,6 +42,7 @@ dependencies:
|
|
|
40
42
|
requirements:
|
|
41
43
|
- - ">="
|
|
42
44
|
- !ruby/object:Gem::Version
|
|
45
|
+
hash: 7
|
|
43
46
|
segments:
|
|
44
47
|
- 3
|
|
45
48
|
- 0
|
|
@@ -55,6 +58,7 @@ dependencies:
|
|
|
55
58
|
requirements:
|
|
56
59
|
- - ">="
|
|
57
60
|
- !ruby/object:Gem::Version
|
|
61
|
+
hash: 27
|
|
58
62
|
segments:
|
|
59
63
|
- 1
|
|
60
64
|
- 3
|
|
@@ -125,6 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
125
129
|
requirements:
|
|
126
130
|
- - ">="
|
|
127
131
|
- !ruby/object:Gem::Version
|
|
132
|
+
hash: 3
|
|
128
133
|
segments:
|
|
129
134
|
- 0
|
|
130
135
|
version: "0"
|
|
@@ -133,6 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
133
138
|
requirements:
|
|
134
139
|
- - ">="
|
|
135
140
|
- !ruby/object:Gem::Version
|
|
141
|
+
hash: 3
|
|
136
142
|
segments:
|
|
137
143
|
- 0
|
|
138
144
|
version: "0"
|
|
@@ -144,14 +150,14 @@ signing_key:
|
|
|
144
150
|
specification_version: 3
|
|
145
151
|
summary: User authentication for Rails 3 applications.
|
|
146
152
|
test_files:
|
|
153
|
+
- test/facebook_token_test.rb
|
|
154
|
+
- test/session_controller_api_test.rb
|
|
155
|
+
- test/user_test.rb
|
|
147
156
|
- test/cookie_controller_test.rb
|
|
157
|
+
- test/test_helper.rb
|
|
148
158
|
- test/facebook_controller_test.rb
|
|
149
|
-
- test/facebook_token_test.rb
|
|
150
159
|
- test/helpers/application_controller.rb
|
|
151
|
-
- test/helpers/db_setup.rb
|
|
152
|
-
- test/helpers/fbgraph.rb
|
|
153
160
|
- test/helpers/routes.rb
|
|
161
|
+
- test/helpers/fbgraph.rb
|
|
162
|
+
- test/helpers/db_setup.rb
|
|
154
163
|
- test/helpers/view_helpers.rb
|
|
155
|
-
- test/session_controller_api_test.rb
|
|
156
|
-
- test/test_helper.rb
|
|
157
|
-
- test/user_test.rb
|