Class: HumbleAuth::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/humble_auth/auth.rb

Class Method Summary collapse

Instance Method Summary collapse

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

#checkObject



28
29
30
# File 'lib/humble_auth/auth.rb', line 28

def check
  @store[:authentication_salt] == salt
end

#required?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/humble_auth/auth.rb', line 12

def required?
  @config
end

#resetObject



32
33
34
# File 'lib/humble_auth/auth.rb', line 32

def reset
  @store.delete(:authentication_salt)
end

#saveObject



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. && password == @config.password
  else
    true
  end
end