Class: ServiceDesk::CustomEmailVerification

Inherits:
ApplicationRecord show all
Defined in:
app/models/service_desk/custom_email_verification.rb

Constant Summary collapse

TIMEFRAME =
30.minutes
STATES =
{ started: 0, finished: 1, failed: 2 }.freeze

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Class Method Details

.generate_tokenObject



96
97
98
# File 'app/models/service_desk/custom_email_verification.rb', line 96

def generate_token
  SecureRandom.alphanumeric(12)
end

Instance Method Details

#accepted_untilObject



101
102
103
104
105
106
# File 'app/models/service_desk/custom_email_verification.rb', line 101

def accepted_until
  return unless started?
  return unless triggered_at.present?

  TIMEFRAME.since(triggered_at)
end

#in_timeframe?Boolean

Returns:

  • (Boolean)


108
109
110
111
112
# File 'app/models/service_desk/custom_email_verification.rb', line 108

def in_timeframe?
  return false unless started?

  !!accepted_until&.future?
end