Class: CASinoCore::Authenticator::ActiveRecord
- Inherits:
-
Object
- Object
- CASinoCore::Authenticator::ActiveRecord
- Defined in:
- lib/casino_core/authenticator/activerecord/version.rb,
lib/casino_core/authenticator/activerecord.rb
Defined Under Namespace
Classes: AuthDatabase
Constant Summary collapse
- VERSION =
'1.1.6'
Instance Method Summary collapse
-
#initialize(options) ⇒ ActiveRecord
constructor
A new instance of ActiveRecord.
- #validate(username, password) ⇒ Object
Constructor Details
#initialize(options) ⇒ ActiveRecord
Returns a new instance of ActiveRecord.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/casino_core/authenticator/activerecord.rb', line 12 def initialize() @options = eval <<-END class #{self.class.to_s}::#{@options[:table].classify} < AuthDatabase end END @model = "#{self.class.to_s}::#{@options[:table].classify}".constantize @model.establish_connection @options[:connection] end |
Instance Method Details
#validate(username, password) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/casino_core/authenticator/activerecord.rb', line 24 def validate(username, password) @model.verify_active_connections! user = @model.send("find_by_#{@options[:username_column]}!", username) password_from_database = user.send(@options[:password_column]) if valid_password?(password, password_from_database) { username: user.send(@options[:username_column]), extra_attributes: extra_attributes(user) } else false end rescue ActiveRecord::RecordNotFound false end |