Class: LdapLoginsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- LdapLoginsController
- Defined in:
- lib/generators/ldap_auth/templates/ldap_logins_controller.rb
Instance Method Summary collapse
-
#ldap_login ⇒ Object
GET /ldap_login.
-
#ldap_logout ⇒ Object
POST /ldap_logout.
-
#persist_ldap_login ⇒ Object
POST /ldap_login.
Instance Method Details
#ldap_login ⇒ Object
GET /ldap_login
3 4 5 |
# File 'lib/generators/ldap_auth/templates/ldap_logins_controller.rb', line 3 def ldap_login # ldap_logins.erb end |
#ldap_logout ⇒ Object
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_login ⇒ Object
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 persist_ldap_login user = LdapRails::LdapUser.auth params[:username], params[:password] if user.nil? flash[:ldap_login_error] = "Incorrect username or password." redirect_to ldap_login_path 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 |