devise 1.4.3 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise might be problematic. Click here for more details.
- data/CHANGELOG.rdoc +13 -0
- data/Gemfile +3 -1
- data/app/controllers/devise/passwords_controller.rb +2 -1
- data/config/locales/en.yml +1 -0
- data/lib/devise.rb +1 -1
- data/lib/devise/controllers/url_helpers.rb +1 -1
- data/lib/devise/failure_app.rb +7 -3
- data/lib/devise/mapping.rb +14 -4
- data/lib/devise/models/database_authenticatable.rb +1 -1
- data/lib/devise/rails/routes.rb +15 -2
- data/lib/devise/version.rb +1 -1
- data/test/failure_app_test.rb +19 -16
- data/test/integration/authenticatable_test.rb +3 -3
- data/test/integration/recoverable_test.rb +3 -1
- data/test/rails_app/config/boot.rb +3 -8
- data/test/rails_app/config/routes.rb +2 -2
- metadata +4 -4
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
== 1.4.5
|
2
|
+
|
3
|
+
* bug fix
|
4
|
+
* Failure app tries the root path if a session one does not exist
|
5
|
+
* No need to finalize Devise helpers all the time (by github.com/bradleypriest)
|
6
|
+
* Reset password shows proper message if user is not active
|
7
|
+
* `clean_up_passwords` sets the accessors to nil to skip validations
|
8
|
+
|
9
|
+
== 1.4.4
|
10
|
+
|
11
|
+
* bug fix
|
12
|
+
* Do not always skip helpers, instead provide :skip_helpers as option to trigger it manually
|
13
|
+
|
1
14
|
== 1.4.3
|
2
15
|
|
3
16
|
* enhancements
|
data/Gemfile
CHANGED
@@ -2,7 +2,7 @@ source "http://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem "rails", "~> 3.1.0
|
5
|
+
gem "rails", "~> 3.1.0"
|
6
6
|
gem "oa-oauth", '~> 0.2.0', :require => "omniauth/oauth"
|
7
7
|
gem "oa-openid", '~> 0.2.0', :require => "omniauth/openid"
|
8
8
|
|
@@ -14,7 +14,9 @@ group :test do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
platforms :jruby do
|
17
|
+
gem 'activerecord-jdbc-adapter', :git => 'https://github.com/nicksieger/activerecord-jdbc-adapter.git'
|
17
18
|
gem 'activerecord-jdbcsqlite3-adapter'
|
19
|
+
gem 'jruby-openssl'
|
18
20
|
end
|
19
21
|
|
20
22
|
platforms :mri_18 do
|
@@ -32,7 +32,8 @@ class Devise::PasswordsController < ApplicationController
|
|
32
32
|
self.resource = resource_class.reset_password_by_token(params[resource_name])
|
33
33
|
|
34
34
|
if resource.errors.empty?
|
35
|
-
|
35
|
+
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
|
36
|
+
set_flash_message(:notice, flash_message) if is_navigational_format?
|
36
37
|
sign_in(resource_name, resource)
|
37
38
|
respond_with resource, :location => redirect_location(resource_name, resource)
|
38
39
|
else
|
data/config/locales/en.yml
CHANGED
@@ -27,6 +27,7 @@ en:
|
|
27
27
|
passwords:
|
28
28
|
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
|
29
29
|
updated: 'Your password was changed successfully. You are now signed in.'
|
30
|
+
updated_not_active: 'Your password was changed successfully.'
|
30
31
|
send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail"
|
31
32
|
confirmations:
|
32
33
|
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
|
data/lib/devise.rb
CHANGED
@@ -397,7 +397,7 @@ module Devise
|
|
397
397
|
Rails::VERSION::STRING[0,3] != "3.0"
|
398
398
|
end
|
399
399
|
|
400
|
-
#
|
400
|
+
# Regenerates url helpers considering Devise.mapping
|
401
401
|
def self.regenerate_helpers!
|
402
402
|
Devise::Controllers::UrlHelpers.remove_helpers!
|
403
403
|
Devise::Controllers::UrlHelpers.generate_helpers!
|
@@ -25,7 +25,7 @@ module Devise
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.generate_helpers!
|
28
|
-
mappings = Devise.mappings.values.map(&:
|
28
|
+
mappings = Devise.mappings.values.map(&:used_helpers).flatten.uniq
|
29
29
|
routes = Devise::URL_HELPERS.slice(*mappings)
|
30
30
|
|
31
31
|
routes.each do |module_name, actions|
|
data/lib/devise/failure_app.rb
CHANGED
@@ -65,10 +65,14 @@ module Devise
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def redirect_url
|
68
|
-
|
69
|
-
|
68
|
+
opts = {}
|
69
|
+
route = :"new_#{scope}_session_path"
|
70
|
+
opts[:format] = request_format unless skip_format?
|
71
|
+
|
72
|
+
if respond_to?(route)
|
73
|
+
send(route, opts)
|
70
74
|
else
|
71
|
-
|
75
|
+
root_path(opts)
|
72
76
|
end
|
73
77
|
end
|
74
78
|
|
data/lib/devise/mapping.rb
CHANGED
@@ -23,7 +23,7 @@ module Devise
|
|
23
23
|
#
|
24
24
|
class Mapping #:nodoc:
|
25
25
|
attr_reader :singular, :scoped_path, :path, :controllers, :path_names,
|
26
|
-
:class_name, :sign_out_via, :format, :used_routes
|
26
|
+
:class_name, :sign_out_via, :format, :used_routes, :used_helpers
|
27
27
|
alias :name :singular
|
28
28
|
|
29
29
|
# Receives an object and find a scope for it. If a scope cannot be found,
|
@@ -74,11 +74,21 @@ module Devise
|
|
74
74
|
@sign_out_via = options[:sign_out_via] || Devise.sign_out_via
|
75
75
|
@format = options[:format]
|
76
76
|
|
77
|
-
|
77
|
+
singularizer = lambda { |s| s.to_s.singularize.to_sym }
|
78
|
+
|
78
79
|
if options.has_key?(:only)
|
79
|
-
@used_routes = Array(options
|
80
|
+
@used_routes = self.routes & Array(options[:only]).map(&singularizer)
|
81
|
+
else
|
82
|
+
@used_routes = self.routes - Array(options[:skip]).map(&singularizer)
|
83
|
+
end
|
84
|
+
|
85
|
+
if options[:skip_helpers] == true
|
86
|
+
@used_helpers = @used_routes
|
87
|
+
elsif skip = options[:skip_helpers]
|
88
|
+
@used_helpers = self.routes - Array(skip).map(&singularizer)
|
89
|
+
else
|
90
|
+
@used_helpers = self.routes
|
80
91
|
end
|
81
|
-
@used_routes -= Array(options.delete(:skip)).map { |s| s.to_s.singularize.to_sym }
|
82
92
|
end
|
83
93
|
|
84
94
|
# Return modules for the mapping.
|
@@ -45,7 +45,7 @@ module Devise
|
|
45
45
|
|
46
46
|
# Set password and password confirmation to nil
|
47
47
|
def clean_up_passwords
|
48
|
-
self.password = self.password_confirmation =
|
48
|
+
self.password = self.password_confirmation = nil
|
49
49
|
end
|
50
50
|
|
51
51
|
# Update record attributes when :current_password matches, otherwise returns
|
data/lib/devise/rails/routes.rb
CHANGED
@@ -4,8 +4,12 @@ module ActionDispatch::Routing
|
|
4
4
|
# need devise_for mappings already declared to create filters and helpers.
|
5
5
|
def finalize_with_devise!
|
6
6
|
finalize_without_devise!
|
7
|
-
|
8
|
-
|
7
|
+
|
8
|
+
@devise_finalized ||= begin
|
9
|
+
Devise.configure_warden!
|
10
|
+
Devise.regenerate_helpers!
|
11
|
+
true
|
12
|
+
end
|
9
13
|
end
|
10
14
|
alias_method_chain :finalize!, :devise
|
11
15
|
end
|
@@ -104,6 +108,14 @@ module ActionDispatch::Routing
|
|
104
108
|
#
|
105
109
|
# devise_for :users, :only => :sessions
|
106
110
|
#
|
111
|
+
# * :skip_helpers => skip generating Devise url helpers like new_session_path(@user).
|
112
|
+
# This is useful to avoid conflicts with previous routes and is false by default.
|
113
|
+
# It accepts true as option, meaning it will skip all the helpers for the controllers
|
114
|
+
# given in :skip but it also accepts specific helpers to be skipped:
|
115
|
+
#
|
116
|
+
# devise_for :users, :skip => [:registrations, :confirmations], :skip_helpers => true
|
117
|
+
# devise_for :users, :skip_helpers => [:registrations, :confirmations]
|
118
|
+
#
|
107
119
|
# * :format => include "(.:format)" in the generated routes? true by default, set to false to disable:
|
108
120
|
#
|
109
121
|
# devise_for :users, :format => false
|
@@ -161,6 +173,7 @@ module ActionDispatch::Routing
|
|
161
173
|
# end
|
162
174
|
#
|
163
175
|
def devise_for(*resources)
|
176
|
+
@devise_finalized = false
|
164
177
|
options = resources.extract_options!
|
165
178
|
|
166
179
|
options[:as] ||= @scope[:as] if @scope[:as].present?
|
data/lib/devise/version.rb
CHANGED
data/test/failure_app_test.rb
CHANGED
@@ -2,6 +2,10 @@ require 'test_helper'
|
|
2
2
|
require 'ostruct'
|
3
3
|
|
4
4
|
class FailureTest < ActiveSupport::TestCase
|
5
|
+
class RootFailureApp < Devise::FailureApp
|
6
|
+
undef_method :new_user_session_path
|
7
|
+
end
|
8
|
+
|
5
9
|
def self.context(name, &block)
|
6
10
|
instance_eval(&block)
|
7
11
|
end
|
@@ -18,32 +22,31 @@ class FailureTest < ActiveSupport::TestCase
|
|
18
22
|
'warden' => OpenStruct.new(:message => nil)
|
19
23
|
}.merge!(env_params)
|
20
24
|
|
21
|
-
@response = Devise::FailureApp.call(env).to_a
|
25
|
+
@response = (env.delete(:app) || Devise::FailureApp).call(env).to_a
|
22
26
|
@request = ActionDispatch::Request.new(env)
|
23
27
|
end
|
24
28
|
|
25
29
|
context 'When redirecting' do
|
26
|
-
test 'return 302 status' do
|
27
|
-
call_failure
|
28
|
-
assert_equal 302, @response.first
|
29
|
-
end
|
30
|
-
|
31
|
-
test 'return 302 status for wildcard requests' do
|
32
|
-
call_failure 'action_dispatch.request.formats' => nil, 'HTTP_ACCEPT' => '*/*'
|
33
|
-
assert_equal 302, @response.first
|
34
|
-
end
|
35
|
-
|
36
30
|
test 'return to the default redirect location' do
|
37
31
|
call_failure
|
32
|
+
assert_equal 302, @response.first
|
38
33
|
assert_equal 'You need to sign in or sign up before continuing.', @request.flash[:alert]
|
39
34
|
assert_equal 'http://test.host/users/sign_in', @response.second['Location']
|
40
35
|
end
|
41
36
|
|
42
37
|
test 'return to the default redirect location for wildcard requests' do
|
43
38
|
call_failure 'action_dispatch.request.formats' => nil, 'HTTP_ACCEPT' => '*/*'
|
39
|
+
assert_equal 302, @response.first
|
44
40
|
assert_equal 'http://test.host/users/sign_in', @response.second['Location']
|
45
41
|
end
|
46
42
|
|
43
|
+
test 'return to the root path if no session path is available' do
|
44
|
+
call_failure :app => RootFailureApp
|
45
|
+
assert_equal 302, @response.first
|
46
|
+
assert_equal 'You need to sign in or sign up before continuing.', @request.flash[:alert]
|
47
|
+
assert_equal 'http://test.host/', @response.second['Location']
|
48
|
+
end
|
49
|
+
|
47
50
|
test 'uses the proxy failure message as symbol' do
|
48
51
|
call_failure('warden' => OpenStruct.new(:message => :test))
|
49
52
|
assert_equal 'test', @request.flash[:alert]
|
@@ -74,7 +77,7 @@ class FailureTest < ActiveSupport::TestCase
|
|
74
77
|
assert_equal 302, @response.first
|
75
78
|
end
|
76
79
|
end
|
77
|
-
|
80
|
+
|
78
81
|
test 'redirects the correct format if it is a non-html format request' do
|
79
82
|
swap Devise, :navigational_formats => [:js] do
|
80
83
|
call_failure('formats' => :js)
|
@@ -178,7 +181,7 @@ class FailureTest < ActiveSupport::TestCase
|
|
178
181
|
assert @response.third.body.include?('<h2>Sign in</h2>')
|
179
182
|
assert @response.third.body.include?('Invalid email or password.')
|
180
183
|
end
|
181
|
-
|
184
|
+
|
182
185
|
test 'calls the original controller if not confirmed email' do
|
183
186
|
env = {
|
184
187
|
"warden.options" => { :recall => "devise/sessions#new", :attempted_path => "/users/sign_in", :message => :unconfirmed },
|
@@ -187,9 +190,9 @@ class FailureTest < ActiveSupport::TestCase
|
|
187
190
|
}
|
188
191
|
call_failure(env)
|
189
192
|
assert @response.third.body.include?('<h2>Sign in</h2>')
|
190
|
-
assert @response.third.body.include?('You have to confirm your account before continuing.')
|
193
|
+
assert @response.third.body.include?('You have to confirm your account before continuing.')
|
191
194
|
end
|
192
|
-
|
195
|
+
|
193
196
|
test 'calls the original controller if inactive account' do
|
194
197
|
env = {
|
195
198
|
"warden.options" => { :recall => "devise/sessions#new", :attempted_path => "/users/sign_in", :message => :inactive },
|
@@ -198,7 +201,7 @@ class FailureTest < ActiveSupport::TestCase
|
|
198
201
|
}
|
199
202
|
call_failure(env)
|
200
203
|
assert @response.third.body.include?('<h2>Sign in</h2>')
|
201
|
-
assert @response.third.body.include?('Your account was not activated yet.')
|
204
|
+
assert @response.third.body.include?('Your account was not activated yet.')
|
202
205
|
end
|
203
206
|
end
|
204
207
|
end
|
@@ -401,14 +401,14 @@ class AuthenticationOthersTest < ActionController::IntegrationTest
|
|
401
401
|
|
402
402
|
test 'sign in stub in xml format' do
|
403
403
|
get new_user_session_path(:format => 'xml')
|
404
|
-
assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>\n <email></email>\n <password></password>\n</user>\n", response.body
|
404
|
+
assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>\n <email></email>\n <password nil=\"true\"></password>\n</user>\n", response.body
|
405
405
|
end
|
406
406
|
|
407
407
|
test 'sign in stub in json format' do
|
408
408
|
get new_user_session_path(:format => 'json')
|
409
409
|
assert_match '{"user":{', response.body
|
410
410
|
assert_match '"email":""', response.body
|
411
|
-
assert_match '"password":
|
411
|
+
assert_match '"password":null', response.body
|
412
412
|
end
|
413
413
|
|
414
414
|
test 'sign in stub in json with non attribute key' do
|
@@ -416,7 +416,7 @@ class AuthenticationOthersTest < ActionController::IntegrationTest
|
|
416
416
|
get new_user_session_path(:format => 'json')
|
417
417
|
assert_match '{"user":{', response.body
|
418
418
|
assert_match '"other_key":null', response.body
|
419
|
-
assert_match '"password":
|
419
|
+
assert_match '"password":null', response.body
|
420
420
|
end
|
421
421
|
end
|
422
422
|
|
@@ -147,7 +147,7 @@ class PasswordTest < ActionController::IntegrationTest
|
|
147
147
|
reset_password :reset_password_token => user.reload.reset_password_token
|
148
148
|
|
149
149
|
assert_current_url '/'
|
150
|
-
assert_contain 'Your password was changed successfully.'
|
150
|
+
assert_contain 'Your password was changed successfully. You are now signed in.'
|
151
151
|
assert user.reload.valid_password?('987654321')
|
152
152
|
end
|
153
153
|
|
@@ -179,6 +179,8 @@ class PasswordTest < ActionController::IntegrationTest
|
|
179
179
|
request_forgot_password
|
180
180
|
reset_password :reset_password_token => user.reload.reset_password_token
|
181
181
|
|
182
|
+
assert_contain 'Your password was changed successfully.'
|
183
|
+
assert_not_contain 'You are now signed in.'
|
182
184
|
assert_equal new_user_session_path, @request.path
|
183
185
|
assert !warden.authenticated?(:user)
|
184
186
|
end
|
@@ -2,12 +2,7 @@ unless defined?(DEVISE_ORM)
|
|
2
2
|
DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
|
3
3
|
end
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
rescue LoadError
|
8
|
-
require 'rubygems'
|
9
|
-
require 'bundler'
|
10
|
-
Bundler.setup :default, :test, DEVISE_ORM
|
11
|
-
end
|
5
|
+
require 'rubygems'
|
6
|
+
require 'bundler/setup'
|
12
7
|
|
13
|
-
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
8
|
+
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
@@ -52,8 +52,8 @@ Rails.application.routes.draw do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
# Routes for format=false testing
|
55
|
-
devise_for :htmlonly_admin, :class_name => "Admin", :skip => [:confirmations, :unlocks], :path => "htmlonly_admin", :format => false
|
56
|
-
devise_for :htmlonly_users, :class_name => "User", :only => [:confirmations, :unlocks], :path => "htmlonly_users", :format => false
|
55
|
+
devise_for :htmlonly_admin, :class_name => "Admin", :skip => [:confirmations, :unlocks], :path => "htmlonly_admin", :format => false, :skip_helpers => [:confirmations, :unlocks]
|
56
|
+
devise_for :htmlonly_users, :class_name => "User", :only => [:confirmations, :unlocks], :path => "htmlonly_users", :format => false, :skip_helpers => true
|
57
57
|
|
58
58
|
# Other routes for routing_test.rb
|
59
59
|
devise_for :reader, :class_name => "User", :only => :passwords
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 5
|
10
|
+
version: 1.4.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Jos\xC3\xA9 Valim"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-08
|
19
|
+
date: 2011-09-08 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|