kat*_*tan 6 facebook devise omniauth
我正在使用devise/omniauth来进行facebook身份验证并且效果很好.但是,我想添加一个流程,其中现有(非Facebook)用户有能力将他的帐户与Facebook连接.这将需要不同的Facebook权限.所以我似乎找不到两件事
有任何想法吗?谢谢
1 的答案非常简单:只需将 if 路径添加到omniauth_callbacks_controller::process_callback 方法中,如下所示
# If a user is signed in then he is trying to link a new account
if user_signed_in?
if authentication.persisted? # This was a linking operation so send back the user to the account edit page
flash[:success] = I18n.t "controllers.omniauth_callbacks.process_callback.success.link_account",
:provider => registration_hash[:provider].capitalize,
:account => registration_hash[:email]
else
flash[:error] = I18n.t "controllers.omniauth_callbacks.process_callback.error.link_account",
:provider => registration_hash[:provider].capitalize,
:account => registration_hash[:email],
:errors =>authentication.errors
end
redirect_to edit_user_account_path(current_user)
Run Code Online (Sandbox Code Playgroud)
这就是我在我的应用程序中所做的,并且效果很好。
关于问题 2,我不知道如何支持 2 种不同的 facebook 身份验证配置,但是我很难看出这对用户有什么用,因为他们需要在两条路径上获得一致的体验:“使用 facebook 登录”和“将您的帐户链接到 facebook ”。(如果你仍然想走这条路,我会探索的一个想法是创建一个具有独立密钥和配置的新 Facebook 应用程序......)
希望这有帮助。
| 归档时间: |
|
| 查看次数: |
1956 次 |
| 最近记录: |