Sha256: 554ac3a9e7d0ce489d7cb0962c8cc1939031566e95eb53ce270cf3ef8f097f34
Contents?: true
Size: 729 Bytes
Versions: 15
Compression:
Stored size: 729 Bytes
Contents
module Nyauth module Confirmable extend ActiveSupport::Concern included do before_validation :check_confirmation_key, on: :confirm end def confirm self.confirmed_at = Time.current save(context: :confirm) end def confirmed? self.confirmed_at.present? end def request_confirmation self.confirmation_key = SecureRandom.hex(32) self.confirmation_key_expired_at = Time.current + Nyauth.configuration.confirmation_expire_limit save end private def check_confirmation_key if confirmation_key_expired_at.past? errors.add(:confirmation_key, :key_expired) else self.confirmation_key = nil end end end end
Version data entries
15 entries across 15 versions & 1 rubygems