Class: LdapLoginsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/ldap_auth/templates/ldap_logins_controller.rb

Instance Method Summary collapse

Instance Method Details

#ldap_loginObject

GET /ldap_login



3
4
5
# File 'lib/generators/ldap_auth/templates/ldap_logins_controller.rb', line 3

def 
  # ldap_logins.erb
end

#ldap_logoutObject

POST /ldap_logout



28
29
30
31
# File 'lib/generators/ldap_auth/templates/ldap_logins_controller.rb', line 28

def ldap_logout
  session[:ldap_user] = nil
  redirect_to '/'
end

#persist_ldap_loginObject

POST /ldap_login



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/ldap_auth/templates/ldap_logins_controller.rb', line 8

def 
  user = LdapRails::LdapUser.auth params[:username], params[:password]

  if user.nil?
    flash[:ldap_login_error] = "Incorrect username or password."
    redirect_to 
  else
    session[:ldap_user] = user.to_hash
    flash[:notice] = "Logged in as #{user.username}."

    # Clear return_to so it doesn't get re-used if the user logs out
    # and logs in again.
    target = (session[:return_to] || '/')
    session.delete :return_to

    redirect_to target
  end
end