Sha256: 7333326e2f5671f234a63e6837721378323f46b8a13eb42944ac7f581c09f786

Contents?: true

Size: 478 Bytes

Versions: 4

Compression:

Stored size: 478 Bytes

Contents

Warden::Strategies.add(:password) do

  def subdomain
    ActionDispatch::Http::URL.extract_subdomains(request.host, 1)
  end
  
  def valid?
    subdomain.present? && params["user"]
  end
  
  def authenticate!
    return fail! unless account = Mtwarden::Account.find_by(subdomain: subdomain)
    return fail! unless user = account.users.find_by(email: params["user"]["email"])
    return fail! unless user.authenticate(params["user"]["password"])
    success! user
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mtwarden-3.6.1 config/initializers/warden/strategies/password.rb
mtwarden-3.6.0 config/initializers/warden/strategies/password.rb
mtwarden-3.5.1 config/initializers/warden/strategies/password.rb
mtwarden-3.5.0 config/initializers/warden/strategies/password.rb