Module: User::Authentication::ClassMethods

Defined in:
app/models/user/authentication.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(login, password) ⇒ Object

Authenticates a user by their login name and unencrypted password. Returns the user or nil.


34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/models/user/authentication.rb', line 34

def authenticate(, password)
  if configatron.authentication == 'ldap'
    authenticated = authenticate_with_ldap(, password)
    authenticated ? register_or_update_via_ldap() : nil
  elsif configatron.authentication == 'none'
    raise StandardError, 'Can only disable authentication in development' unless Rails.env.development?

    User.find_by(login: )
  else
    authenticated = authenticate_by_local(, password)
  end
end