Class: CASino::StaticAuthenticator
- Inherits:
-
Authenticator
- Object
- Authenticator
- CASino::StaticAuthenticator
- 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
-
#initialize(options) ⇒ StaticAuthenticator
constructor
A new instance of StaticAuthenticator.
- #load_user_data(username) ⇒ Object
- #validate(username, password) ⇒ Object
Constructor Details
#initialize(options) ⇒ StaticAuthenticator
Returns a new instance of StaticAuthenticator.
8 9 10 |
# File 'app/authenticators/casino/static_authenticator.rb', line 8 def initialize() @users = [:users] || {} end |
Instance Method Details
#load_user_data(username) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/authenticators/casino/static_authenticator.rb', line 21 def load_user_data(username) if @users.include?(username) { username: "#{username}", extra_attributes: @users[username].except(:password) } end end |
#validate(username, password) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'app/authenticators/casino/static_authenticator.rb', line 12 def validate(username, password) username = :"#{username}" if @users.include?(username) && @users[username][:password] == password load_user_data(username) else false end end |