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.



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

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

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
end

#siteObject (readonly)

Returns the value of attribute site.



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

def site
  @site
end

Instance Method Details

#actionObject



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

def action
  params[:auth_action]
end

#callbackObject



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

def callback
  params[:auth_callback]
end

#disable_emailObject



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

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

#email_handleObject



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

def email_handle
  params[:auth_email_handle]
end

#entryObject



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

def entry
  params[:auth_entry]
end

#fromObject



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

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

#idObject



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

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

#id_fieldObject



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

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

#passwordObject



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

def password
  params[:auth_password]
end

#password_fieldObject



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

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

#recaptcha_responseObject



189
190
191
# File 'lib/locomotive/steam/middlewares/auth.rb', line 189

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

#reset_password_urlObject



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

def reset_password_url
  params[:auth_reset_password_url]
end

#reset_tokenObject



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

def reset_token
  params[:auth_reset_token]
end

#smtpObject



193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/locomotive/steam/middlewares/auth.rb', line 193

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



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

def smtp_config
  @config ||= _read_smtp_config
end

#subjectObject



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

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

#typeObject



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

def type
  params[:auth_content_type]
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  ACTIONS.include?(action)
end