全身份验证 - 抓住用户被重定向到谷歌的时刻
Omniauth authentication - catch the moment when the user gets redirected to google
# Gemfile
gem 'omniauth'
gem 'omniauth-google-oauth2'
gem 'devise'
# view
- if user_signed_in?
Signed in as
= current_user.oauth_name
= button_to('Sign out', destroy_user_session_path, method: :delete)
- else
= link_to('Sign in with Google', user_omniauth_authorize_path(:google_oauth2))
捕捉用户被重定向到谷歌进行身份验证的最佳方法是什么?
它可能是通过"javascript onclick",但我想以某种方式在服务器上捕捉时刻(如果可能的话),因为我需要将一些变量保存到会话中。
有一个可以使用的初始化回调列表。我想你需要OmniAuth.config.before_request_phase
#config/initializers/omniauth.rb
OmniAuth.config.before_request_phase do |env|
env['omniauth.auth']
# Your code there
end
相关文章:
- 如何使用谷歌分析在页面重定向之前跟踪事件
- 全身份验证 - 抓住用户被重定向到谷歌的时刻
- 谷歌分析调用然后用javascript重定向
- 谷歌索引和重定向
- 谷歌CSE-我可以显示嵌入在我的网站上的页面本身,而不是从结果视图重定向到页面
- 使用变量和谷歌跟踪代码管理器重写和重定向网址
- 当将页面提交到谷歌表单时,它将打印结果,然后使用 javascript 重定向到主页
- 通过AJAX提交谷歌表单后,停止页面重定向
- 重定向页面覆盖谷歌搜索中的真实页面
- 提交旧的谷歌表单,然后重定向到另一个页面
- jquery-1.6.4.min.js自动重定向到谷歌主页
- Javascript重定向与谷歌分析
- 谷歌Chrome浏览器的Javascript重定向问题
- 谷歌Chrome不活动重定向
- 如何重定向一些页面在谷歌chrome扩展
- 关闭或重定向标签上成功的谷歌认证
- 如何获取优步登录页面,然后重定向到声明页面使用谷歌应用程序脚本
- 重置谷歌Chrome扩展背景页面变量
- 我可以重定向谷歌分析片段到我的服务器
- 如何重定向谷歌网站上的URL