Add a deprecation warning for previous controller authorization style.

This commit is contained in:
José Valim 2011-09-22 11:50:57 +02:00
parent dd1d128333
commit ab9d856568
4 changed files with 17 additions and 3 deletions

View File

@ -1,3 +1,8 @@
== 1.4.7
* bug fix
* Fix backward incompatible change from 1.4.6 for those using custom controllers
== 1.4.6
* enhancements

View File

@ -1,6 +1,6 @@
class Devise::SessionsController < ApplicationController
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
before_filter :allow_params_authentication!, :only => :create
prepend_before_filter :allow_params_authentication!, :only => :create
include Devise::Controllers::InternalHelpers
# GET /resource/sign_in

View File

@ -182,7 +182,6 @@ module ActionDispatch::Routing
options[:path_names] = (@scope[:path_names] || {}).merge(options[:path_names] || {})
options[:constraints] = (@scope[:constraints] || {}).merge(options[:constraints] || {})
options[:defaults] = (@scope[:defaults] || {}).merge(options[:defaults] || {})
@scope[:options] = (@scope[:options] || {}).merge({:format => false}) if options[:format] == false
resources.map!(&:to_sym)

View File

@ -85,7 +85,17 @@ module Devise
# By default, a request is valid if the controller is allowed and the VERB is POST.
def valid_request?
env["devise.allow_params_authentication"]
if env["devise.allow_params_authentication"]
true
elsif request.post? && mapping.controllers[:sessions] == params[:controller]
ActiveSupport::Deprecation.warn "It seems that you are using a custom SessionsController. " \
"In order for it to work from Devise 1.4.6 forward, you need to add the following:" \
"\n\n prepend_before_filter :allow_params_authentication!, :only => :create\n\n" \
"This will ensure your controller can authenticate from params for the create action.", caller
true
else
false
end
end
# If the request is valid, finally check if params_auth_hash returns a hash.