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.



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/models/user/authentication.rb', line 38

def authenticate(, password)
  case configatron.authentication
  when 'ldap'
    authenticated = authenticate_with_ldap(, password)
    authenticated ? register_or_update_via_ldap() : nil
  when '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