Move user access check to Gitlab::UserAccess

This commit is contained in:
Jacob Vosmaer 2014-05-15 10:17:13 +02:00
parent 6d45909f03
commit 34fd557055
2 changed files with 19 additions and 12 deletions

View file

@ -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

18
lib/gitlab/user_access.rb Normal file
View file

@ -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