1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Issue 675: recall option is now passed for not confirmed email and inactive account.

This commit is contained in:
siong1987 2010-12-23 02:17:11 +08:00 committed by José Valim
parent 13e8bc22e3
commit 379d8c69a5
3 changed files with 27 additions and 5 deletions

View file

@ -40,7 +40,7 @@ module Devise
def recall
env["PATH_INFO"] = attempted_path
flash.now[:alert] = i18n_message(:invalid)
flash.now[:alert] = i18n_message(warden_options[:message] || :invalid)
self.response = recall_app(warden_options[:recall]).call(env)
end

View file

@ -4,8 +4,8 @@
# in each request and in case the user is using other strategies beside Devise ones.
Warden::Manager.after_set_user do |record, warden, options|
if record && record.respond_to?(:active?) && !record.active?
scope = options[:scope]
warden.logout(scope)
throw :warden, :scope => scope, :message => record.inactive_message
warden.logout(options[:scope])
options.merge!(:message => record.inactive_message)
throw :warden, options
end
end

View file

@ -144,7 +144,7 @@ class FailureTest < ActiveSupport::TestCase
end
context 'With recall' do
test 'calls the original controller' do
test 'calls the original controller if invalid email or password' do
env = {
"warden.options" => { :recall => "devise/sessions#new", :attempted_path => "/users/sign_in" },
"devise.mapping" => Devise.mappings[:user],
@ -154,5 +154,27 @@ class FailureTest < ActiveSupport::TestCase
assert @response.third.body.include?('<h2>Sign in</h2>')
assert @response.third.body.include?('Invalid email or password.')
end
test 'calls the original controller if not confirmed email' do
env = {
"warden.options" => { :recall => "devise/sessions#new", :attempted_path => "/users/sign_in", :message => :unconfirmed },
"devise.mapping" => Devise.mappings[:user],
"warden" => stub_everything
}
call_failure(env)
assert @response.third.body.include?('<h2>Sign in</h2>')
assert @response.third.body.include?('You have to confirm your account before continuing.')
end
test 'calls the original controller if inactive account' do
env = {
"warden.options" => { :recall => "devise/sessions#new", :attempted_path => "/users/sign_in", :message => :inactive },
"devise.mapping" => Devise.mappings[:user],
"warden" => stub_everything
}
call_failure(env)
assert @response.third.body.include?('<h2>Sign in</h2>')
assert @response.third.body.include?('Your account was not activated yet.')
end
end
end