Logging with OmniAuth and Devise RoR 5

171 Views Asked by At

I am following the docs from here LINK.

This is Users::OmniAuthCallbacksController facebook method:

def facebook
    # You need to implement the method below in your model (e.g. app/models/user.rb)
    @user = User.from_omniauth(request.env["omniauth.auth"])

    if @user.persisted?
        logger.debug "YES"
        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
        logger.debug "No"
        session["devise.facebook_data"] = request.env["omniauth.auth"]
    end
end

This is part of 'application.html.erb' view

<h1><%=user_signed_in? %></h1>

If I try to login with Facebook it creates new row in users table for this user, it works, but I see user_signed_in? is false. What I need to do to authenticate with Devise and OmniAuth ?

0

There are 0 best solutions below