![](/img/trans.png)
[英]Devise Google Omniauth working in Local, but not in Production
[英]Rails 6 omniauth working on local but not production (Heroku)
我有一个:
身份验证失败:#<Hash.... 的未定义方法“bytesize”...
这是我的链接的样子:
<%= link_to t('navbar.loginf'), user_facebook_omniauth_authorize_path, method: :post, class: "is-fullwidth" %>
<%= link_to t('navbar.loging'), user_google_oauth2_omniauth_authorize_path, method: :post, class: "is-fullwidth" %>
这是 omniauth controller:
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
@user = User.from_omniauth(request.env['omniauth.auth'])
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 google_oauth2
@user = User.from_omniauth(request.env['omniauth.auth'])
if @user.persisted?
sign_in_and_redirect @user
set_flash_message(:notice, :success, kind: 'Google') if is_navigational_format?
else
flash[:error] = I18n.t('alert.gge')
redirect_to new_user_registration_url
end
end
def failure
redirect_to root_path
end
end
查找问题:
-必须更新 yarn.lock 文件(删除 yarn.lock 文件并在终端上运行 yarn install 命令,它将生成一个新的 yarn.lock )
-此版本在 heroku 上有所不同
"@babel/parser@^7.16.7", "@babel/parser@^7.17.3":
-Google 回调调用 JS 文件以使用我们请求的参数点击操作。
- 所以 Omniauth 需要解析它但它不能这样做,因为 babel 没有正确解析它并将它交给 omniauth.rb 的 auth_hash 方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.