Commit 826404a8 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Open/close LDAP in ApplicationController

By opening the LDAP connection at the controller level we can reuse it
for all LDAP queries during the request.

Conflicts:
	CHANGELOG
	app/controllers/application_controller.rb
parent 2f1a59d3
...@@ -183,8 +183,9 @@ class ApplicationController < ActionController::Base ...@@ -183,8 +183,9 @@ class ApplicationController < ActionController::Base
def ldap_security_check def ldap_security_check
if current_user && current_user.ldap_user? && current_user.requires_ldap_check? if current_user && current_user.ldap_user? && current_user.requires_ldap_check?
if gitlab_ldap_access.allowed?(current_user) gitlab_ldap_access do |access|
gitlab_ldap_access.update_permissions(current_user) if access.allowed?(current_user)
access.update_permissions(current_user)
current_user.last_credential_check_at = Time.now current_user.last_credential_check_at = Time.now
current_user.save current_user.save
else else
...@@ -194,14 +195,15 @@ class ApplicationController < ActionController::Base ...@@ -194,14 +195,15 @@ class ApplicationController < ActionController::Base
end end
end end
end end
end
def event_filter def event_filter
filters = cookies['event_filter'].split(',') if cookies['event_filter'].present? filters = cookies['event_filter'].split(',') if cookies['event_filter'].present?
@event_filter ||= EventFilter.new(filters) @event_filter ||= EventFilter.new(filters)
end end
def gitlab_ldap_access def gitlab_ldap_access(&block)
Gitlab::LDAP::Access.new Gitlab::LDAP::Access.open { |access| block.call(access) }
end end
# JSON for infinite scroll via Pager object # JSON for infinite scroll via Pager object
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment