Commit 9ea80a19 authored by Rémy Coutable's avatar Rémy Coutable

Fix condition in Ability and start with cheaper checks

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 22ba5d8a
...@@ -157,9 +157,9 @@ class Ability ...@@ -157,9 +157,9 @@ class Ability
# Push abilities on the users team role # Push abilities on the users team role
rules.push(*project_team_rules(project.team, user)) rules.push(*project_team_rules(project.team, user))
owner = project.owner == user || owner = user.admin? ||
(project.group && project.group.has_owner?(user)) || project.owner == user ||
user.admin? (project.group && project.group.has_owner?(user))
if owner if owner
rules.push(*project_owner_rules) rules.push(*project_owner_rules)
...@@ -178,7 +178,7 @@ class Ability ...@@ -178,7 +178,7 @@ class Ability
project.group.requesters.exists?(user_id: user.id) project.group.requesters.exists?(user_id: user.id)
) )
rules << :request_access unless owner || project.team.member?(user) || group_member rules << :request_access unless owner || group_member || project.team.member?(user)
end end
if project.archived? if project.archived?
...@@ -355,8 +355,8 @@ class Ability ...@@ -355,8 +355,8 @@ class Ability
rules = [] rules = []
rules << :read_group if can_read_group?(user, group) rules << :read_group if can_read_group?(user, group)
owner = group.has_owner?(user) || user.admin? owner = user.admin? || group.has_owner?(user)
master = owner || user.admin? master = owner || group.has_master?(user)
# Only group masters and group owners can create new projects # Only group masters and group owners can create new projects
if master if master
...@@ -376,7 +376,7 @@ class Ability ...@@ -376,7 +376,7 @@ class Ability
] ]
end end
if (group.public? || (group.internal? && !user.external?)) if group.public? || (group.internal? && !user.external?)
rules << :request_access unless group.users.include?(user) rules << :request_access unless group.users.include?(user)
end end
......
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