我正在关注此处的文档LINK。
这是Users::OmniAuthCallbacksController
facebook
方法:
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
这是' application.html.erb'的一部分。图
<h1><%=user_signed_in? %></h1>
如果我尝试使用Facebook登录,则会在此users
表格中为该用户创建新行,但它有效,但我看到user_signed_in?
为false
。
我需要做些什么来验证Devise和OmniAuth?