diff options
author | Andreas Brandl <abrandl@gitlab.com> | 2018-03-02 18:01:06 +0300 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2018-03-02 20:23:03 +0300 |
commit | 39011be53daee921dac1648044d1e68b9706197c (patch) | |
tree | 695cbcfa7346f2d4f8a4c566bd6f0ae31dd4f5c5 /app/models/user.rb | |
parent | 0a3fc7e3c283c10ef8415a719e83e80f0122af7d (diff) |
Extract method User#authorizations_for_projects.
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 9547506d33d..9c60adf0c90 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -601,6 +601,15 @@ class User < ActiveRecord::Base authorized_projects(min_access_level).exists?({ id: project.id }) end + # Typically used in conjunction with projects table to get projects + # a user has been given access to. + # + # Example use: + # `Project.where('EXISTS(?)', user.authorizations_for_projects)` + def authorizations_for_projects + project_authorizations.select(1).where('project_authorizations.project_id = projects.id') + end + # Returns the projects this user has reporter (or greater) access to, limited # to at most the given projects. # |