Omniauth-facebook取消按钮 [英] Omniauth-facebook cancel button

查看:152
本文介绍了Omniauth-facebook取消按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始将facebook身份验证集成到我的Rails 3.1站点中,但是当我点击fb auth对话框上的取消按钮时遇到问题。当我点击取消,我被重定向回我的网站在/ auth / Facebook /回调,然后重定向到/登录页面(我正在使用Devise)。

I've started integrating facebook authentication into my Rails 3.1 site, but ran into an issue when I click the cancel button on the fb auth dialog. When I click cancel, I get redirected back to my site at /auth/facebook/callback and then redirected to the /login page (I'm using Devise).

我想要做的是将取消的授权重定向到允许用户以标准方式(电子邮件,用户名,密码等)创建帐户的页面。如何覆盖重定向到/登录页面?

What I want to do is redirect a canceled auth to a page that allows the user to create an account the standard way (email, username, password, etc). How can I override the redirect to the /login page?

Btw,我正在使用omniauth-facebook宝石。

Btw, I'm using the omniauth-facebook gem.

谢谢!

推荐答案

在您的omniauth回调控制器中添加失败方法,并定义您的自定义行为。

Add failure method in your omniauth callback controller and define your customized behavior.

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def facebook
        @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)

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

  def failure
    redirect_to root_path // here
  end

end

这篇关于Omniauth-facebook取消按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆