authpwn_rails 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/authpwn_rails.gemspec +3 -3
- data/lib/authpwn_rails/session.rb +7 -3
- data/lib/authpwn_rails/user_model.rb +6 -0
- data/test/user_test.rb +8 -0
- metadata +5 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.5
|
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.7.
|
8
|
+
s.version = "0.7.5"
|
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{2011-03-
|
12
|
+
s.date = %q{2011-03-17}
|
13
13
|
s.description = %q{Works with Facebook.}
|
14
14
|
s.email = %q{victor@costan.us}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
|
|
59
59
|
]
|
60
60
|
s.homepage = %q{http://github.com/pwnall/authpwn_rails}
|
61
61
|
s.require_paths = ["lib"]
|
62
|
-
s.rubygems_version = %q{1.
|
62
|
+
s.rubygems_version = %q{1.6.0}
|
63
63
|
s.summary = %q{User authentication for Rails 3 applications.}
|
64
64
|
s.test_files = [
|
65
65
|
"test/cookie_controller_test.rb",
|
@@ -84,7 +84,7 @@ module ControllerInstanceMethods
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
# Included in controllers that call
|
87
|
+
# Included in controllers that call authpwn_session_controller.
|
88
88
|
module SessionControllerInstanceMethods
|
89
89
|
# GET /session/new
|
90
90
|
def new
|
@@ -110,7 +110,9 @@ module SessionControllerInstanceMethods
|
|
110
110
|
respond_to do |format|
|
111
111
|
format.html { render :action => :home }
|
112
112
|
format.json do
|
113
|
-
|
113
|
+
user_data = @user.as_json
|
114
|
+
user_data = user_data['user'] if @user.class.include_root_in_json
|
115
|
+
render :json => { :user => user_data,
|
114
116
|
:csrf => form_authenticity_token }
|
115
117
|
end
|
116
118
|
end
|
@@ -129,7 +131,9 @@ module SessionControllerInstanceMethods
|
|
129
131
|
if current_user
|
130
132
|
format.html { redirect_to @redirect_url }
|
131
133
|
format.json do
|
132
|
-
|
134
|
+
user_data = @user.as_json
|
135
|
+
user_data = user_data['user'] if @user.class.include_root_in_json
|
136
|
+
render :json => { :user => user_data,
|
133
137
|
:csrf => form_authenticity_token }
|
134
138
|
end
|
135
139
|
else
|
@@ -111,6 +111,12 @@ module ModelInstanceMethods
|
|
111
111
|
def to_param
|
112
112
|
email
|
113
113
|
end
|
114
|
+
|
115
|
+
# Do not expose password and ActiveRecord IDs in JSON representation.
|
116
|
+
def as_json(options = {})
|
117
|
+
options ||= {}
|
118
|
+
super(options.merge(:except => [:password_salt, :password_hash, :id]))
|
119
|
+
end
|
114
120
|
end # module AuthpwnRails::UserModel::ModelInstanceMethods
|
115
121
|
|
116
122
|
ActiveRecord::Base.send :include, ModelMixin
|
data/test/user_test.rb
CHANGED
@@ -81,6 +81,14 @@ class UserTest < ActiveSupport::TestCase
|
|
81
81
|
assert_equal nil, User.find_by_param(nil)
|
82
82
|
end
|
83
83
|
|
84
|
+
test 'to_json does not show implementation details' do
|
85
|
+
json_data = ActiveSupport::JSON.decode users(:john).to_json
|
86
|
+
assert_operator json_data, :has_key?, 'user'
|
87
|
+
assert_nil json_data['user']['password_hash']
|
88
|
+
assert_nil json_data['user']['password_salt']
|
89
|
+
assert_nil json_data['user']['id']
|
90
|
+
end
|
91
|
+
|
84
92
|
test 'find_by_email_and_password' do
|
85
93
|
assert_equal users(:john),
|
86
94
|
User.find_by_email_and_password('john@gmail.com', 'password')
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authpwn_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 5
|
10
|
+
version: 0.7.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Victor Costan
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-17 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
requirements: []
|
146
146
|
|
147
147
|
rubyforge_project:
|
148
|
-
rubygems_version: 1.
|
148
|
+
rubygems_version: 1.6.0
|
149
149
|
signing_key:
|
150
150
|
specification_version: 3
|
151
151
|
summary: User authentication for Rails 3 applications.
|