Class: HumbleAuth::Auth
- Inherits:
-
Object
- Object
- HumbleAuth::Auth
- Defined in:
- lib/humble_auth/auth.rb
Class Method Summary collapse
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(config, store) ⇒ Auth
constructor
A new instance of Auth.
- #required? ⇒ Boolean
- #reset ⇒ Object
- #save ⇒ Object
- #validate(username, password) ⇒ Object
Constructor Details
#initialize(config, store) ⇒ Auth
Returns a new instance of Auth.
7 8 9 10 |
# File 'lib/humble_auth/auth.rb', line 7 def initialize(config, store) @config = config @store = store end |
Class Method Details
.make_config(config) ⇒ Object
3 4 5 |
# File 'lib/humble_auth/auth.rb', line 3 def self.make_config(config) config ? ActiveSupport::OrderedOptions[config.symbolize_keys.to_a] : false end |
Instance Method Details
#check ⇒ Object
28 29 30 |
# File 'lib/humble_auth/auth.rb', line 28 def check @store[:authentication_salt] == salt end |
#required? ⇒ Boolean
12 13 14 |
# File 'lib/humble_auth/auth.rb', line 12 def required? @config end |
#reset ⇒ Object
32 33 34 |
# File 'lib/humble_auth/auth.rb', line 32 def reset @store.delete(:authentication_salt) end |
#save ⇒ Object
24 25 26 |
# File 'lib/humble_auth/auth.rb', line 24 def save @store[:authentication_salt] = { :value => salt, :expires => 1.week.from_now } end |
#validate(username, password) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/humble_auth/auth.rb', line 16 def validate(username, password) if @config username == @config.login && password == @config.password else true end end |