Skip to content

Commit

Permalink
[api] Drop conditional check when iterating through group relations
Browse files Browse the repository at this point in the history
Since we iterate through group relations, we already know that each item
has a group associated. No need to check this again.
  • Loading branch information
bgeuken committed Mar 28, 2017
1 parent 804f0dc commit ec646ab
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/api/app/models/project.rb
Expand Up @@ -362,18 +362,17 @@ def self.check_access?(dbp)
# dbp.id, User.current
dbp.relationships.groups.includes(:group).each do |grouprel|
# check if User.current belongs to group
if grouprel && grouprel.group_id
# LOCAL
# if user is in group -> return true
ret += 1 if User.current.is_in_group?(grouprel.group)
# LDAP
# FIXME: please do not do special things here for ldap. please cover this in a generic group model.
if CONFIG['ldap_mode'] == :on && CONFIG['ldap_group_support'] == :on
if UserLdapStrategy.user_in_group_ldap?(User.current, grouprel.group_id)
ret += 1
end
# LOCAL
# if user is in group -> return true
ret += 1 if User.current.is_in_group?(grouprel.group)
# LDAP
# FIXME: please do not do special things here for ldap. please cover this in a generic group model.
if CONFIG['ldap_mode'] == :on && CONFIG['ldap_group_support'] == :on
if UserLdapStrategy.user_in_group_ldap?(User.current, grouprel.group_id)
ret += 1
end
end
#
end
# relationship to package -> access
return true if ret > 0
Expand Down

0 comments on commit ec646ab

Please sign in to comment.