Class: Locomotive::Steam::Middlewares::Auth::AuthOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/locomotive/steam/middlewares/auth.rb

Constant Summary collapse

ACTIONS =
%w(sign_up sign_in sign_out forgot_password reset_password)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site, params) ⇒ AuthOptions

Returns a new instance of AuthOptions.



116
117
118
# File 'lib/locomotive/steam/middlewares/auth.rb', line 116

def initialize(site, params)
  @site, @params = site, params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



114
115
116
# File 'lib/locomotive/steam/middlewares/auth.rb', line 114

def params
  @params
end

#siteObject (readonly)

Returns the value of attribute site.



114
115
116
# File 'lib/locomotive/steam/middlewares/auth.rb', line 114

def site
  @site
end

Instance Method Details

#actionObject



124
125
126
# File 'lib/locomotive/steam/middlewares/auth.rb', line 124

def action
  params[:auth_action]
end

#callbackObject



148
149
150
# File 'lib/locomotive/steam/middlewares/auth.rb', line 148

def callback
  params[:auth_callback]
end

#disable_emailObject



172
173
174
# File 'lib/locomotive/steam/middlewares/auth.rb', line 172

def disable_email
  [1, '1', 'true', true].include?(params[:auth_disable_email])
end

#email_handleObject



168
169
170
# File 'lib/locomotive/steam/middlewares/auth.rb', line 168

def email_handle
  params[:auth_email_handle]
end

#entryObject



176
177
178
# File 'lib/locomotive/steam/middlewares/auth.rb', line 176

def entry
  params[:auth_entry]
end

#fromObject



160
161
162
# File 'lib/locomotive/steam/middlewares/auth.rb', line 160

def from
  smtp_config['sender'] || '[email protected]'
end

#idObject



140
141
142
# File 'lib/locomotive/steam/middlewares/auth.rb', line 140

def id
  params[:auth_entry].try(:[], id_field) || params[:auth_id]
end

#id_fieldObject



132
133
134
# File 'lib/locomotive/steam/middlewares/auth.rb', line 132

def id_field
  params[:auth_id_field] || :email
end

#passwordObject



144
145
146
# File 'lib/locomotive/steam/middlewares/auth.rb', line 144

def password
  params[:auth_password]
end

#password_fieldObject



136
137
138
# File 'lib/locomotive/steam/middlewares/auth.rb', line 136

def password_field
  params[:auth_password_field].try(:to_sym) || :password
end

#recaptcha_responseObject



184
185
186
# File 'lib/locomotive/steam/middlewares/auth.rb', line 184

def recaptcha_response
  params["g-recaptcha-response"]
end

#reset_password_urlObject



152
153
154
# File 'lib/locomotive/steam/middlewares/auth.rb', line 152

def reset_password_url
  params[:auth_reset_password_url]
end

#reset_tokenObject



156
157
158
# File 'lib/locomotive/steam/middlewares/auth.rb', line 156

def reset_token
  params[:auth_reset_token]
end

#smtpObject



188
189
190
191
192
193
194
195
196
197
198
199
200
201
# 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_configObject



180
181
182
# File 'lib/locomotive/steam/middlewares/auth.rb', line 180

def smtp_config
  @config ||= _read_smtp_config
end

#subjectObject



164
165
166
# File 'lib/locomotive/steam/middlewares/auth.rb', line 164

def subject
  params[:auth_email_subject] || 'Instructions for changing your password'
end

#typeObject



128
129
130
# File 'lib/locomotive/steam/middlewares/auth.rb', line 128

def type
  params[:auth_content_type]
end

#valid?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/locomotive/steam/middlewares/auth.rb', line 120

def valid?
  ACTIONS.include?(action)
end