小编amu*_*nda的帖子

使用像facebook这样的omniauth提供程序时,Devise不会正确地重定向到存储位置

我在我的应用程序中有一些受保护并需要用户身份验证的操作.由于我正在使用设计,我使用authenticate_user!在过滤之前保护它们.每当用户点击受保护的页面时,设计要求用户登录,然后重定向回受保护的页面.这部分很完美.

问题是当用户尝试通过我的应用程序使用Facebook登录时,设计在登录后不会将用户重定向到受保护的页面.它总是将用户返回到根URL.使用标准身份验证,这不是问题

我怀疑它与passthru方法有关 - 设计 - omniauth集成需要.任何帮助将不胜感激

这是我的omniauth回调的代码片段:

def facebook
# You need to implement the method below in your model
omniauth = request.env["omniauth.auth"]
@user = User.find_for_facebook_oauth(omniauth, 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"] = env["omniauth.auth"]
  redirect_to new_user_registration_url
end
end

def passthru
  render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
end
Run Code Online (Sandbox Code Playgroud)

facebook ruby-on-rails devise

10
推荐指数
1
解决办法
3173
查看次数

标签 统计

devise ×1

facebook ×1

ruby-on-rails ×1