BCrypt::Errors::InvalidHash 生产中 Rails 错误

BCrypt::Errors::InvalidHash error in Rails In production

我无法在我的生产站点上通过 LinkedIn 注册用户。它显示这样的错误:

Completed 500 Internal Server Error in 202ms (ActiveRecord: 3.8ms)
[f842309d-189a-4edc-bafb-a6a567ea8fcd]   
[f842309d-189a-4edc-bafb-a6a567ea8fcd] BCrypt::Errors::InvalidHash (invalid hash):
[f842309d-189a-4edc-bafb-a6a567ea8fcd]   
[f842309d-189a-4edc-bafb-a6a567ea8fcd] app/models/user.rb:82:in `from_omniauth'
[f842309d-189a-4edc-bafb-a6a567ea8fcd] app/controllers/users/omniauth_callbacks_controller.rb:9:in `linkedin'

它在我的本地机器上工作正常。

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
    def linkedin
      @user = User.from_omniauth(auth_hash, current_user, session)
      remember_me(@user)
      session[:user_id] = @user.id
      if !(@user.img_url == auth_hash.info.picture_url)
        @user.update_attributes(:img_url => auth_hash.info.picture_url)
      end
      if not @user.persisted?
        session["devise.linkedin_data"] = auth_hash
        render body: session.to_json
      end
      sign_in_and_redirect(:user, @user)
    end
end

用户模型

def self.from_omniauth(auth, signed_in=nil, session)
  user.password = Devise.friendly_token unless user.encrypted_password.present?
end

有人可以帮助我理解这个错误以及我可以如何修复它吗?

您是否正确设置了所有设备配置密码?在生产服务器上检查您的设计初始化程序和 ENV 变量。我认为服务器缺少一个 ENV 变量来告诉 bcrypt 使用什么盐来存储密码

您是否尝试过将您的 bcrypt 升级到 3.1.12

这里是link到GITHUB ISSUE