Sha256: 1e17b31585f5c1aa58c96b9b591a7a0e30cf85474f94b7ab806f3017618c7cf6

Contents?: true

Size: 670 Bytes

Versions: 1

Compression:

Stored size: 670 Bytes

Contents

# frozen_string_literal: true

module Aikotoba
  class Account::UnlockToken < ApplicationRecord
    include TokenEncryptable
    belongs_to :account, class_name: "Aikotoba::Account", foreign_key: "aikotoba_account_id"
    validates :token, presence: true
    validates :expired_at, presence: true

    scope :active, ->(now: Time.current) { where("expired_at >= ?", now) }

    after_initialize do |record|
      token = Account::Value::Token.new(extipry: Aikotoba.unlock_token_expiry)
      record.token ||= token.value
      record.expired_at ||= token.expired_at
    end

    def notify
      AccountMailer.with(account: account).unlock.deliver_now
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aikotoba-0.1.0 app/models/aikotoba/account/unlock_token.rb