Question

I am having a strange issue with Pow and Omniauth. Omniauth (Facebook Login) works fine when using localhost:3000, but when using Pow (appname.dev) things get fishy.

Users are taken through the redirect and properly created if they don't exist in the database, as they should be. After this, however, they are redirected to the root_path and not signed in. Their record is saved in the database as expected, but sign in does not occur. Again, this is only happening on Pow (and lvh.me), and not on localhost.

Any ideas?

I am using the Devise/Omniauth approach for sign-in, and the controller code looks like this:

  def facebook

    @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)

    if @user.persisted?
      flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
      sign_in_and_redirect @user, :event => :authentication
    else
      session["devise.facebook_data"] = request.env["omniauth.auth"]
      redirect_to new_user_registration_url
    end
  end

Again, the user is persisted but there is no flash notice or sign_in that occurs when using POW.

Was it helpful?

Solution

Check that the session is being set as something may be preventing it (like needing to clear browser cookies in your case.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top