我用Devise和omniauth创建了一个rails应用程序来进行fb注册。 一切正常,但是当我在注册后重定向到最后一页时,我对来自fb的用户的flash消息有错误。
这是我的application_controller
def set_redirect_path
@redirect_path = request.path
end
def after_sign_in_path_for(resource)
if params[:redirect_to].present?
store_location_for(resource, params[:redirect_to])
elsif request.referer == new_session_url(:user)
super
else
request.env['omniauth.origin'] || stored_location_for(resource) || request.referer || root_path
end
end
这里是omniauth_callbacks_controller
def facebook
@user = User.from_omniauth(request.env["omniauth.auth"])
if @user.persisted?
sign_in_and_redirect @user, :event => :authentication
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
end
我在注册和从Facebook重定向后得到的flash消息是已经认证的错误一个说"您已经登录了。"
有谁知道如何解决这个问题
感谢
答案 0 :(得分:0)
解决方法是更改after_sign_in_path_for方法。例如,在ApplicationController中:
USE [DCSTransfer]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[InsertTags]
@Badge = N'9046',
@StartTag = N'80996',
@Qty = 70
SELECT 'Return Value' = @return_value
GO