File: password.rb

package info (click to toggle)
ruby-warden 1.2.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 360 kB
  • sloc: ruby: 3,261; makefile: 4
file content (14 lines) | stat: -rw-r--r-- 450 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# encoding: utf-8
# frozen_string_literal: true
Warden::Strategies.add(:password) do
  def authenticate!
    request.env['warden.spec.strategies'] ||= []
    request.env['warden.spec.strategies'] << :password
    if params["password"] || params["username"]
      params["password"] == "sekrit" && params["username"] == "fred" ?
        success!("Authenticated User") : fail!("Username or password is incorrect")
    else
      pass
    end
  end
end