Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does sign_in_and_redirect in devise work?

if @user.persisted?
      sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
      set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
else
      session["devise.facebook_data"] = request.env["omniauth.auth"]
      redirect_to new_user_registration_url
end

This method is present in the facebook omniauth callbacks controller. The problem that I am facing is that I do not get the user's phone number from facebook and thus @user is not a valid object (I have a validation). So, I want to redirect the user to another page where I can ask for the phone number.

How can I modify the sign_in_and_redirect @user to redirect me to that page and not the root url.

like image 387
user2441151 Avatar asked Sep 09 '15 05:09

user2441151


1 Answers

Sign_in_and_redirect method uses after_sign_in_path_for method to determine where to redirect the user after sign in.

You can easily customize your after_sign_in_path_for method to check for the phone presence and either call super or redirect to the page where user can enter their phone number.

like image 111
ddgd Avatar answered Sep 20 '22 14:09

ddgd