From ebbabaea5b21cd28cdf2a8fc3b718ba6255da318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81my=20Coutable?= Date: Thu, 1 Sep 2011 00:24:10 +0200 Subject: [PATCH] After a password reset, don't show "You are now signed in." if the user can't be signed-in anyway. --- app/controllers/devise/passwords_controller.rb | 3 ++- config/locales/en.yml | 1 + test/integration/recoverable_test.rb | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/devise/passwords_controller.rb b/app/controllers/devise/passwords_controller.rb index b0f8acc0..857b23b0 100644 --- a/app/controllers/devise/passwords_controller.rb +++ b/app/controllers/devise/passwords_controller.rb @@ -32,7 +32,8 @@ class Devise::PasswordsController < ApplicationController self.resource = resource_class.reset_password_by_token(params[resource_name]) if resource.errors.empty? - set_flash_message(:notice, :updated) if is_navigational_format? + flash_message = resource.active_for_authentication? ? :updated : :updated_not_active + set_flash_message(:notice, flash_message) if is_navigational_format? sign_in(resource_name, resource) respond_with resource, :location => redirect_location(resource_name, resource) else diff --git a/config/locales/en.yml b/config/locales/en.yml index 80c84bba..b1826351 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -27,6 +27,7 @@ en: passwords: send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.' updated: 'Your password was changed successfully. You are now signed in.' + updated_not_active: 'Your password was changed successfully.' send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail" confirmations: send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' diff --git a/test/integration/recoverable_test.rb b/test/integration/recoverable_test.rb index f72b4571..a9093aef 100644 --- a/test/integration/recoverable_test.rb +++ b/test/integration/recoverable_test.rb @@ -147,7 +147,7 @@ class PasswordTest < ActionController::IntegrationTest reset_password :reset_password_token => user.reload.reset_password_token assert_current_url '/' - assert_contain 'Your password was changed successfully.' + assert_contain 'Your password was changed successfully. You are now signed in.' assert user.reload.valid_password?('987654321') end @@ -179,6 +179,8 @@ class PasswordTest < ActionController::IntegrationTest request_forgot_password reset_password :reset_password_token => user.reload.reset_password_token + assert_contain 'Your password was changed successfully.' + assert_not_contain 'You are now signed in.' assert_equal new_user_session_path, @request.path assert !warden.authenticated?(:user) end