Reputation: 157
I am unable to register a user via LinkedIn on my production site. Its showing an error like this :
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'
It's working fine in my local machine.
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
User Model
def self.from_omniauth(auth, signed_in=nil, session)
user.password = Devise.friendly_token unless user.encrypted_password.present?
end
Can someone help me understand this error and how I may be able to fix it, please?
Upvotes: 1
Views: 749
Reputation: 76
Have you tried upgrading your bcrypt to 3.1.12
?
Here is the link to GITHUB ISSUE
Upvotes: 2
Reputation: 2727
Have you set all devise config secrets correctly? Check your devise initializer and your ENV variables on your production server. I think the server is missing a ENV variablee to tell bcrypt what salt to use to store the password
Upvotes: 0