mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Do not rely on controller being available in params.
This commit is contained in:
parent
b6089145c1
commit
c12d75eecf
3 changed files with 6 additions and 6 deletions
|
@ -10,7 +10,7 @@ class Devise::SessionsController < ApplicationController
|
|||
|
||||
# POST /resource/sign_in
|
||||
def create
|
||||
resource = warden.authenticate!(:scope => resource_name, :recall => "new")
|
||||
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_name}#new")
|
||||
set_flash_message :notice, :signed_in
|
||||
sign_in_and_redirect(resource_name, resource)
|
||||
end
|
||||
|
|
|
@ -41,7 +41,7 @@ module Devise
|
|||
def recall
|
||||
env["PATH_INFO"] = attempted_path
|
||||
flash.now[:alert] = i18n_message(:invalid)
|
||||
self.response = recall_controller.action(warden_options[:recall]).call(env)
|
||||
self.response = recall_app(warden_options[:recall]).call(env)
|
||||
end
|
||||
|
||||
def redirect
|
||||
|
@ -94,8 +94,9 @@ module Devise
|
|||
{}.respond_to?(method) ? { :error => i18n_message }.send(method) : i18n_message
|
||||
end
|
||||
|
||||
def recall_controller
|
||||
"#{params[:controller].camelize}Controller".constantize
|
||||
def recall_app(app)
|
||||
controller, action = app.split("#")
|
||||
"#{controller.camelize}Controller".constantize.action(action)
|
||||
end
|
||||
|
||||
def warden
|
||||
|
|
|
@ -136,8 +136,7 @@ class FailureTest < ActiveSupport::TestCase
|
|||
context 'With recall' do
|
||||
test 'calls the original controller' do
|
||||
env = {
|
||||
"action_dispatch.request.parameters" => { :controller => "devise/sessions" },
|
||||
"warden.options" => { :recall => "new", :attempted_path => "/users/sign_in" },
|
||||
"warden.options" => { :recall => "devise/sessions#new", :attempted_path => "/users/sign_in" },
|
||||
"devise.mapping" => Devise.mappings[:user],
|
||||
"warden" => stub_everything
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue