English 中文(简体)
冲锋枪
原标题:Omniauth-facebook cancel button

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).

我想做的是,将一个被注销的 au改到一页,使用户能够以标准方式(电子邮件、用户名称、密码等)编制账户。 我怎么能凌驾于转往 /log页之上?

Btw, I m using the omniauth-facebook gem.

感谢!

问题回答

在您的统称背心控制器中添加失败方法,并界定你定制的行为。

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

我认为,你也许能够推翻你在座的conf中对“失败行为”的默认,我不使用设计,而是使用总括手册,并在以下各方面取得了成功:

OmniAuth.config.on_failure = Proc.new { |env|
  OmniAuth::FailureEndpoint.new(env).redirect_to_failure
} 

或更多习俗,如:

OmniAuth.config.on_failure do |env|
  new_path = "#{env[ SCRIPT_NAME ]}#{OmniAuth.config.path_prefix}/failure?message=#{error_type}"

  [302, { Location  => new_path,  Content-Type =>  text/html }, []]
end




相关问题
Facebook Connect login dialog not working

I am using Facebook Connect for iPhone and following the official instructions. I use the following code to display the login dialog: FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:...

Facebook App Profile Tab is Empty ... No Content Displayed?

I can view my application via the http://apps.facebook.com/myapplication/ link and the content shows up correctly. I also added the application as a tab to a facebook page. However, when viewing the ...

Facebook Platform error: "Object cannot be liked"

I m working on a Facebook Application that generates wall posts. In testing these posts, I ve discovered that the Facebook Platform action of "liking" a post is failing. The specific error message ...

how to call showPermissionsDialog() in php (facebook api)?

I was reading over the documentation yet I could not figure out how to call Facebook.showPermissionsDialog() in php include_once ./facebook-platform/php/facebook.php ; $facebook = new Facebook(my ...

Facebook connect

If I plug in the facebook connect into my website, How can I prevent double signups? Lets say I have a user that s already signed up to my site but he clicked the connect with facebook, is there a ...

热门标签