Sha256: 4733117935c063e58ea281bb146a6d0e8c7d3dc4d10cfd70b01310e32757dfc2
Contents?: true
Size: 876 Bytes
Versions: 2
Compression:
Stored size: 876 Bytes
Contents
require 'active_support/concern' module DovecotCramMD5Password extend ActiveSupport::Concern included do validates :password_unencrypted, length: { minimum: 5 }, allow_blank: true validates_confirmation_of :password_unencrypted, allow_blank: true validate do |record| record.errors.add(:password_unencrypted, :blank) unless record.password.present? end attr_reader :password_unencrypted attr_accessor :password_unencrypted_confirmation end def password_unencrypted=(unencrypted_password) if unencrypted_password.nil? self.password = nil elsif !unencrypted_password.empty? @password_unencrypted = unencrypted_password self.password = DovecotCrammd5.calc(unencrypted_password) end end def authenticate(unencrypted_password) password == DovecotCrammd5.calc(unencrypted_password) && self end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
postfix_admin-0.2.1 | lib/postfix_admin/concerns/dovecot_cram_md5_password.rb |
postfix_admin-0.2.0 | lib/postfix_admin/concerns/dovecot_cram_md5_password.rb |