lib/puavo_authentication/controllers/helpers.rb in puavo_authentication-0.0.17 vs lib/puavo_authentication/controllers/helpers.rb in puavo_authentication-0.0.18

- old
+ new

@@ -5,11 +5,16 @@ unless session[:dn].nil? unless @current_user.nil? return @current_user else begin - return @current_user = User.find(session[:dn]) # REST/OAuth? + if session[:dn].to_s.match(/ou=People/) + return @current_user = User.find(session[:dn]) + else + # If user is ExternalService return nil + logger.info "current_user is ExternalServier user: #{session[:dn]}" + end rescue logger.info "Session's user not found! User is removed from ldap server." logger.info "session[:dn]: #{session[:dn]}" # Delete ldap connection informations from session. session.delete :password_plaintext @@ -93,9 +98,16 @@ Puavo::Authorization.organisation_owner? end def set_authorization_user Puavo::Authorization.current_user = current_user if current_user + end + + def remove_authorization_user + if Puavo::Authorization.current_user + logger.debug "Remove authorization user: " + Puavo::Authorization.current_user.dn.inspect + end + Puavo::Authorization.current_user = nil end end end end