Rails Devise, how to unencrypt a password?

前端 未结 4 947
醉梦人生
醉梦人生 2021-01-02 21:28

in rails 3 devise, a user record has an encrypted_password and a password_salt.

How in the console, can I obtain a user\'s password? How to unencrypt?

4条回答
  •  一整个雨季
    2021-01-02 21:56

    class User < ActiveRecord::Base
    
      devise :database_authenticatable...
    
      def verify_password?(password)
        encryptor_class = Devise::Encryptors.const_get(Devise.encryptor.to_s.classify)
        encryptor_digest = encryptor_class.digest(password, Devise.stretches, self.password_salt, Devise.pepper)
        encryptor_digest == self.encrypted_password
      end
    end
    

提交回复
热议问题