diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2016-11-18 20:15:47 +0300 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2016-11-23 13:57:58 +0300 |
commit | 916332815e33c655f727a28457f655f6425306ae (patch) | |
tree | 8d8166e3a6cbcacb2abd7ca5182639e87d8589b1 /app | |
parent | 229b7e9a8e10d51eca057e7948a48935011cc51a (diff) |
Drop Project#authorized_for_user? in favor of ProjectTeam#member?
Closes #23938
Diffstat (limited to 'app')
-rw-r--r-- | app/models/issue.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 8 | ||||
-rw-r--r-- | app/models/project_team.rb | 8 |
3 files changed, 7 insertions, 11 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 6e8f5d3c422..dd0cb75f9a8 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -93,7 +93,7 @@ class Issue < ActiveRecord::Base # Check if we are scoped to a specific project's issues if owner_project - if owner_project.authorized_for_user?(user, Gitlab::Access::REPORTER) + if owner_project.team.member?(user, Gitlab::Access::REPORTER) # If the project is authorized for the user, they can see all issues in the project return all else diff --git a/app/models/project.rb b/app/models/project.rb index 76c1fc4945d..4408c29a54d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1293,14 +1293,6 @@ class Project < ActiveRecord::Base end end - # Checks if `user` is authorized for this project, with at least the - # `min_access_level` (if given). - def authorized_for_user?(user, min_access_level = nil) - return false unless user - - user.authorized_project?(self, min_access_level) - end - def append_or_update_attribute(name, value) old_values = public_send(name.to_s) diff --git a/app/models/project_team.rb b/app/models/project_team.rb index 65549d8cd08..5845203055a 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -141,8 +141,12 @@ class ProjectTeam max_member_access(user.id) == Gitlab::Access::MASTER end - def member?(user, min_member_access = Gitlab::Access::GUEST) - max_member_access(user.id) >= min_member_access + # Checks if `user` is authorized for this project, with at least the + # `min_access_level` (if given). + def member?(user, min_access_level = Gitlab::Access::GUEST) + return false unless user + + user.authorized_project?(project, min_access_level) end def human_max_access(user_id) |