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.



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

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

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
end

#siteObject (readonly)

Returns the value of attribute site.



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

def site
  @site
end

Instance Method Details

#actionObject



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

def action
  params[:auth_action]
end

#callbackObject



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

def callback
  params[:auth_callback]
end

#disable_emailObject



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

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

#email_handleObject



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

def email_handle
  params[:auth_email_handle]
end

#entryObject



187
188
189
# File 'lib/locomotive/steam/middlewares/auth.rb', line 187

def entry
  params[:auth_entry]
end

#fromObject



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

def from
  params[:auth_email_from] || '[email protected]'
end

#idObject



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

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

#id_fieldObject



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

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

#passwordObject



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

def password
  params[:auth_password]
end

#password_fieldObject



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

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

#reset_password_urlObject



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

def reset_password_url
  params[:auth_reset_password_url]
end

#reset_tokenObject



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

def reset_token
  params[:auth_reset_token]
end

#smtpObject



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

def smtp
  name = params[:auth_email_smtp_namespace] || 'smtp'
  namespace = site.metafields.try(:[], name)

  if namespace.blank?
    Locomotive::Common::Logger.error "[Auth] Missing SMTP settings in the Site metafields. Namespace: #{name}".light_red
    return {}
  end

  {
    address:    namespace[params[:auth_email_smtp_address_alias] || 'address'],
    port:       namespace[params[:auth_email_smtp_port_alias] || 'port'],
    user_name:  namespace[params[:auth_email_smtp_user_name_alias] || 'user_name'],
    password:   namespace[params[:auth_email_smtp_password_alias] || 'password']
  }
end

#subjectObject



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

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

#typeObject



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

def type
  params[:auth_content_type]
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  ACTIONS.include?(action)
end