Class: CASino::StaticAuthenticator

Inherits:
Authenticator show all
Defined in:
app/authenticators/casino/static_authenticator.rb

Overview

The static authenticator is just a simple example. Never use this authenticator in a productive environment!

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ StaticAuthenticator

Returns a new instance of StaticAuthenticator.

Parameters:

  • options (Hash)


8
9
10
# File 'app/authenticators/casino/static_authenticator.rb', line 8

def initialize(options)
  @users = options[:users] || {}
end

Instance Method Details

#validate(username, password) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'app/authenticators/casino/static_authenticator.rb', line 12

def validate(username, password)
  username = :"#{username}"
  if @users.include?(username) && @users[username][:password] == password
    {
      username: "#{username}",
      extra_attributes: @users[username].except(:password)
    }
  else
    false
  end
end