From 34fd557055e027b6423241e73b7cf26c741c0b6b Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 15 May 2014 10:17:13 +0200 Subject: [PATCH] Move user access check to Gitlab::UserAccess --- lib/gitlab/git_access.rb | 13 +------------ lib/gitlab/user_access.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 lib/gitlab/user_access.rb diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index f3e781a..4f49ca4 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -61,18 +61,7 @@ module Gitlab private def user_allowed?(user) - return false if user.blocked? - - if Gitlab.config.ldap.enabled - if user.ldap_user? - # Check if LDAP user exists and match LDAP user_filter - Gitlab::LDAP::Access.open do |adapter| - return false unless adapter.allowed?(user) - end - end - end - - true + Gitlab::UserAccess.allowed?(user) end end end diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb new file mode 100644 index 0000000..16df21b --- /dev/null +++ b/lib/gitlab/user_access.rb @@ -0,0 +1,18 @@ +module Gitlab + module UserAccess + def self.allowed?(user) + return false if user.blocked? + + if Gitlab.config.ldap.enabled + if user.ldap_user? + # Check if LDAP user exists and match LDAP user_filter + Gitlab::LDAP::Access.open do |adapter| + return false unless adapter.allowed?(user) + end + end + end + + true + end + end +end -- libgit2 0.21.2