Sha256: 1393d22560f39818ebd5b20838f898c1bef4fc428dcfa7150f81289f29b53cb8

Contents?: true

Size: 477 Bytes

Versions: 5

Compression:

Stored size: 477 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

5 entries across 5 versions & 1 rubygems

Version Path
mtwarden-4.1.2 config/initializers/warden/strategies/password.rb
mtwarden-4.1.1 config/initializers/warden/strategies/password.rb
mtwarden-4.1.0 config/initializers/warden/strategies/password.rb
mtwarden-4.0.0 config/initializers/warden/strategies/password.rb
mtwarden-3.6.2 config/initializers/warden/strategies/password.rb