Guest User

Untitled

a guest
Jan 23rd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. module Devise
  2.  
  3. module PasswordEncryptionMigration
  4.  
  5. def valid_password?(incoming_password)
  6. if using_authlogic_validation?
  7. Devise.secure_compare(authlogic_password_digest(incoming_password), self.crypted_password).tap do |validated|
  8. if validated
  9. self.password = incoming_password
  10. self.crypted_password = nil
  11. self.save(:validate => false)
  12. end
  13. end
  14. else
  15. Devise.secure_compare(password_digest(incoming_password), self.encrypted_password)
  16. end
  17. end
  18.  
  19. def using_authlogic_validation?
  20. self.encrypted_password.blank?
  21. end
  22.  
  23. def authlogic_password_digest(password)
  24. if self.password_salt.present?
  25. Devise::Encryptors::AuthlogicSha512.digest(password, 20, self.password_salt, nil)
  26. end
  27. end
  28.  
  29. end
  30.  
  31. end
Add Comment
Please, Sign In to add comment