Sha256: 28926d787de5649533a8d206fd0d45701a07e5e660f5a749076580669248f35a
Contents?: true
Size: 685 Bytes
Versions: 7
Compression:
Stored size: 685 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 + 1.hour save end private def check_confirmation_key if confirmation_key_expired_at.past? errors.add(:confirmation_key, :expired) else self.confirmation_key = nil end end end end
Version data entries
7 entries across 7 versions & 1 rubygems