0

我将设计和omniauth设置为authen,用facebook登录后,我创建一个用户并为用户生成密码

user = User.new :fullname => auth_hash['extra']['raw_info']['name'], 
:email =>auth_hash['extra']['raw_info']['email'], 
:encrypted_password => Devise.friendly_token[0,20]

但是当我尝试使用我的 facebook 用户 (http://localhost:3000/users/sign_in) 登录时,出现错误:

BCrypt::Errors::InvalidHash in Devise::SessionsController#create 
invalid hash

要求

参数:

{"utf8"=>"✓",
 "authenticity_token"=>"/xA0goLirKlI2YWSLSMQk+3a8xDrVmrhqIjhILh0OME=",
 "user"=>{"email"=>"xxx@gmail.com",
 "password"=>"[FILTERED]",
 "remember_me"=>"1"},
 "commit"=>"Sign in"} 
4

1 回答 1

0

默认情况下,Devise 使用 bcrypt 的加密密码算法,所以我的猜测是您尝试手动输入密码的加密版本时遇到问题。您是否尝试过简单地设置一个 :password 值而不是 :encrypted_pa​​ssword?如:

user = User.new :fullname => auth_hash['extra']['raw_info']['name'], 
:email =>auth_hash['extra']['raw_info']['email'], 
:password => Devise.friendly_token[0,20]
于 2012-06-04T00:46:28.293 回答