class Locomotive::Steam::Middlewares::Auth::AuthOptions

Constants

ACTIONS

Attributes

params[R]
site[R]

Public Class Methods

new(site, params) click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 116
def initialize(site, params)
  @site, @params = site, params
end

Public Instance Methods

action() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 124
def action
  params[:auth_action]
end
callback() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 148
def callback
  params[:auth_callback]
end
disable_email() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 172
def disable_email
  [1, '1', 'true', true].include?(params[:auth_disable_email])
end
email_handle() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 168
def email_handle
  params[:auth_email_handle]
end
entry() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 176
def entry
  params[:auth_entry]
end
from() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 160
def from
  smtp_config['sender'] || 'support@locomotivecms.com'
end
id() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 140
def id
  params[:auth_entry].try(:[], id_field) || params[:auth_id]
end
id_field() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 132
def id_field
  params[:auth_id_field] || :email
end
password() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 144
def password
  params[:auth_password]
end
password_field() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 136
def password_field
  params[:auth_password_field].try(:to_sym) || :password
end
recaptcha_response() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 184
def recaptcha_response
  params["g-recaptcha-response"]
end
reset_password_url() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 152
def reset_password_url
  params[:auth_reset_password_url]
end
reset_token() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 156
def reset_token
  params[:auth_reset_token]
end
smtp() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 188
def smtp
  if smtp_config.blank?
    {}
  else
    {
      address:              smtp_config['address'],
      port:                 smtp_config['port'],
      user_name:            smtp_config['user_name'],
      password:             smtp_config['password'],
      authentication:       smtp_config['authentication'] || 'plain',
      enable_starttls_auto: (smtp_config['enable_starttls_auto'] || "0").to_bool,
    }
  end
end
smtp_config() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 180
def smtp_config
  @config ||= _read_smtp_config
end
subject() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 164
def subject
  params[:auth_email_subject] || 'Instructions for changing your password'
end
type() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 128
def type
  params[:auth_content_type]
end
valid?() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 120
def valid?
  ACTIONS.include?(action)
end

Private Instance Methods

_read_smtp_config() click to toggle source
# File lib/locomotive/steam/middlewares/auth.rb, line 205
def _read_smtp_config
  name = params[:auth_email_smtp_namespace] || 'smtp'
  config = site.metafields.try(:[], name)
  if config.blank?
    Locomotive::Common::Logger.error "[Auth] Missing SMTP settings in the Site metafields. Namespace: #{name}".light_red
    {}
  else
    config
  end
end