Sha256: 95874f40ef522cad4708604a277f5164fc9d6cccb62863369ad12b60bd14e4e9
Contents?: true
Size: 1.04 KB
Versions: 62
Compression:
Stored size: 1.04 KB
Contents
# # Hold onto a secure password supporting both storage (setting) and retrieval ()getting) the password. # # The security will lie in the key that is offered by the object. By default it will be the ID of the object # however it should really use be combined with some other known value like account.id or something # module EncryptedPassword extend ActiveSupport::Concern # # Base class extension # def self.included(base) base.class_eval do include CipherAble # # Fields # field :encrypted_password, type: String end end # # Retrieve the password # def password encrypted_password.present? ? cipher.decrypt_and_verify(encrypted_password) : '' rescue StandardError => error App47Logger.log_warn("Unable to retrieve password for #{inspect}", error) nil end # # Set the password # def password=(pass) set encrypted_password: cipher.encrypt_and_sign(pass) rescue StandardError => error App47Logger.log_error("Unable to store password for #{inspect}", error) nil end end
Version data entries
62 entries across 62 versions & 1 rubygems