From 40c0a7b50b7728d2e473fe3e33e15a48bf3cbf70 Mon Sep 17 00:00:00 2001 From: Rodrigo Flores Date: Mon, 20 Jun 2011 23:03:01 -0300 Subject: [PATCH] Added paranoid mode to lockable --- app/controllers/devise/unlocks_controller.rb | 14 ++++++++++---- config/locales/en.yml | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/devise/unlocks_controller.rb b/app/controllers/devise/unlocks_controller.rb index bc773aa4..0f5585a9 100644 --- a/app/controllers/devise/unlocks_controller.rb +++ b/app/controllers/devise/unlocks_controller.rb @@ -12,11 +12,17 @@ class Devise::UnlocksController < ApplicationController def create self.resource = resource_class.send_unlock_instructions(params[resource_name]) - if resource.errors.empty? - set_flash_message :notice, :send_instructions if is_navigational_format? - respond_with resource, :location => new_session_path(resource_name) - else + if Devise.paranoid + set_flash_message :notice, :send_paranoid_instructions if is_navigational_format? + resource.errors.clear respond_with_navigational(resource){ render_with_scope :new } + else + if resource.errors.empty? + set_flash_message :notice, :send_instructions if is_navigational_format? + respond_with resource, :location => new_session_path(resource_name) + else + respond_with_navigational(resource){ render_with_scope :new } + end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 099a6103..a5cf3bf6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -40,6 +40,7 @@ en: unlocks: send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' unlocked: 'Your account was successfully unlocked. You are now signed in.' + send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.' omniauth_callbacks: success: 'Successfully authorized from %{kind} account.' failure: 'Could not authorize you from %{kind} because "%{reason}".'