Commit c6d39a14 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add User#requires_ldap_check? method

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent cf890b22
......@@ -181,7 +181,7 @@ class ApplicationController < ActionController::Base
end
def ldap_security_check
if current_user && current_user.ldap_user? && current_user.requires_ldap_check?
if current_user && current_user.requires_ldap_check?
if gitlab_ldap_access.allowed?(current_user)
current_user.last_credential_check_at = Time.now
current_user.save
......
......@@ -275,7 +275,9 @@ class User < ActiveRecord::Base
# Projects user has access to
def authorized_projects
@authorized_projects ||= begin
project_ids = (personal_projects.pluck(:id) + groups_projects.pluck(:id) + projects.pluck(:id)).uniq
project_ids = personal_projects.pluck(:id)
project_ids += groups_projects.pluck(:id)
project_ids += projects.pluck(:id).uniq
Project.where(id: project_ids).joins(:namespace).order('namespaces.name ASC')
end
end
......@@ -406,6 +408,14 @@ class User < ActiveRecord::Base
end
end
def requires_ldap_check?
if ldap_user?
!last_credential_check_at || (last_credential_check_at + 1.hour) < Time.now
else
false
end
end
def solo_owned_groups
@solo_owned_groups ||= owned_groups.select do |group|
group.owners == [self]
......
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