Class: Sinatra::WardenPlugin::PasswordStrategy
- Inherits:
-
Warden::Strategies::Base
- Object
- Warden::Strategies::Base
- Sinatra::WardenPlugin::PasswordStrategy
- Defined in:
- lib/sinatra/warden_plugin.rb
Overview
This is the basic password strategy for authentication
Instance Method Summary collapse
Instance Method Details
#authenticate! ⇒ Object
16 17 18 19 20 |
# File 'lib/sinatra/warden_plugin.rb', line 16 def authenticate! raise "Please either define a user class or set Sinatra::WardenPlugin::PasswordStrategy.user_class" unless user_class u = user_class.authenticate(username, password) u.nil? ? fail!("Could not log in") : success!(u) end |
#password ⇒ Object
26 27 28 |
# File 'lib/sinatra/warden_plugin.rb', line 26 def password params['password'] || params['pass'] end |
#username ⇒ Object
22 23 24 |
# File 'lib/sinatra/warden_plugin.rb', line 22 def username params['username'] || params['nickname'] || params['login'] || params['email'] end |
#valid? ⇒ Boolean
12 13 14 |
# File 'lib/sinatra/warden_plugin.rb', line 12 def valid? username || password end |