在Devise sign_in(用户)之后,current_user暂时为零

时间:2014-11-20 08:16:07

标签: facebook ruby-on-rails-4 devise omniauth

我正在使用omniAuth + facebook身份验证

@user = User.find_for_facebook_oauth(request.env["omniauth.auth"])
  if @user.persisted?

    @user.reload
    sign_in @user, :event => :authentication

    redirect_to after_sign_in_path_for(@user)
    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

在facebook登录后,用户登陆根网址,当尝试打开/帐户/个人资料时会发出未经授权的错误。但几秒后/帐户/配置文件变得可访问。为什么会有延迟?

   class AccountController < ApplicationController
     layout false
     def profile

       if !current_user
         render status: 401
         return
       end
     end

0 个答案:

没有答案