W Decide how to allow SignIn to log in as another user

My application automatically creates a guest user account. The problem is that the guest user may want to log into a real account.

So I want Sign In users to already subscribe_in? in accordance with the invention.

While I can display the form, if I submit the signin form, devus kicks it into redirecting:

Started POST "/users/sign_in" for 127.0.0.1 at 2011-07-19 18:21:45 -0700
  Processing by Devise::SessionsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"RE/xxx=", "user"=>{"email"=>"sally.jones@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Sign In"}
  User Load (0.6ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 102 LIMIT 1
Redirected to http://localhost:3000/
Completed 302 Found in 266ms

Update

I tried:

class SessionsController < Devise::SessionsController

  def create
    Rails.logger.info 'XXXXX 2'
    super
    Rails.logger.info 'XXXXX 4'
  end

end

But the developer seems to throw the request before it even hits this method, and the log is not in the log file

Any ideas on how I can let the login_in subscriber log in?

+5
source share
3

, , , current_{resource} ? , sign_in sign_up ( , prepend_before_filter :require_no_authentication).

... , , , , .

:

https://github.com/plataformatec/devise/blob/master/app/controllers/devise_controller.rb

require_no_authentication, , . guest_users

:

P.S. , {resource} - . , , , downcasing.

class RegistrationsController < Devise::RegistrationsController
  before_filter :require_no_authentication, :unless => :guest_user?, :only => [:new,:create, :cancel]
  before_filter :require_no_authentication_for_guests, :if => :guest_user?, :only => [:new,:create, :cancel]

  private

  def guest_user?
    current_{resource}.is_guest?
  end

  def require_no_authentication_for_guests
    assert_is_devise_resource!
  end 
end

:

Class {resource}
  def is_guest?
    # here you put the code that distinguishes a guest user which should return true if its one>
  end
end

:

,

devise_for :users, :controllers => {:sessions => "sessions",
                                  :registrations => "registrations"}

. .

, .

?

+3

You can do 2 actions. The first of them issues and redirects to the second, which initiates a new image by another user.

0
source

All Articles