Class: SmtpConfiguration
- Inherits:
-
Object
- Object
- SmtpConfiguration
- Includes:
- StandardModel
- Defined in:
- lib/app/models/smtp_configuration.rb
Overview
SMTP Configuration for an account
Instance Method Summary collapse
-
#secure_fields ⇒ Object
Which fields to protect.
-
#update_token ⇒ Object
Update the token on save if we are active and the token is not already set.
-
#use? ⇒ Boolean
If we can use this SMTP configuration or not, it must be confirmed and activate.
-
#validate_token(token) ⇒ Object
Validate the token, returning true of false if valid.
Methods included from StandardModel
#audit_action, #auto_strip_attributes, #capture_user_info, #clear_cache, #created_by_display_name, #delete_and_log, #destroy_and_log, included, #last_modified_by_display_name, #log_change, #log_deletion, #remove_blank_secure_fields, #save_and_log, #save_and_log!, #update, #update!, #update_and_log, #update_and_log!
Methods included from App47Logger
clean_params, #clean_params, delete_parameter_keys, #log_controller_error, log_debug, #log_debug, log_error, #log_error, log_exception, #log_message, log_message, #log_warn, log_warn, mask_parameter_keys, #update_flash_messages
Instance Method Details
#secure_fields ⇒ Object
Which fields to protect
43 44 45 |
# File 'lib/app/models/smtp_configuration.rb', line 43 def secure_fields super + %i[password] end |
#update_token ⇒ Object
Update the token on save if we are active and the token is not already set.
64 65 66 67 68 69 70 71 72 |
# File 'lib/app/models/smtp_configuration.rb', line 64 def update_token if active? set(confirmation_token: Digest::SHA256.hexdigest("#{id}_#{account.id}")) if confirmation_token.nil? set(confirmed: false) set(verification_message: 'Sending SMTP verification email(s) to SMTP admins.') else set(verification_message: 'SMTP Configuration is not active, no verification email will be sent.') end end |
#use? ⇒ Boolean
If we can use this SMTP configuration or not, it must be confirmed and activate. Otherwise we return false.
36 37 38 |
# File 'lib/app/models/smtp_configuration.rb', line 36 def use? confirmed? && active? end |
#validate_token(token) ⇒ Object
Validate the token, returning true of false if valid
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/app/models/smtp_configuration.rb', line 50 def validate_token(token) valid = if confirmation_token.present? && confirmation_token.eql?(token) unset(:confirmation_token, :verification_message) true else false end set(confirmed: valid) valid end |