diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-03-11 10:24:07 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-03-11 10:24:07 +0200 |
commit | c6d39a14d6b15f457bfc050f54e256cd5da64cc9 (patch) | |
tree | 620a0ded1dd3174e26eae1fcf80fcc5cc87747a4 /app/models | |
parent | cf890b227a277086dd1b5cfee356027f1a77a424 (diff) | |
download | gitlab-ce-c6d39a14d6b15f457bfc050f54e256cd5da64cc9.tar.gz |
Add User#requires_ldap_check? method
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/user.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 855fe58ffe8..a9ee471ad61 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -185,7 +185,7 @@ class User < ActiveRecord::Base where(conditions).first end end - + def find_for_commit(email, name) # Prefer email match over name match User.where(email: email).first || @@ -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] |