3
我是從PHP遷移到Rails的遷移用戶數據庫。我已經安裝了Devise Gem,現在它運行良好。另外,我發現一個提示如何遷移現有用戶的密碼到Rails 我已經加入舊密碼相同encrypted_password
字段設計成立,所以當色器件沒有權威性,檢查舊密碼:將密碼遷移到設計
# user.rb
def valid_password?(password)
return false if encrypted_password.blank?
require 'digest/sha1'
password_salt = 'my_php_framework_salt'
Devise.secure_compare(Digest::SHA1.hexdigest(password_salt+password), self.encrypted_password)
end
它允許使用舊密碼登錄,但不適用於新用戶的原始設計密碼。我認爲這個valid_password?
方法應該return true
設計密碼。如何解決這個問題?