Fixed a bug where a user could see every namespace

This commit is contained in:
konrad 2018-09-06 08:39:05 +02:00 committed by kolaente
parent f2758e239c
commit 92174aac08
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -67,8 +67,9 @@ func (n *Namespace) checkTeamRights(user *User, r TeamRight) bool {
Table("namespaces"). Table("namespaces").
Join("LEFT", "team_namespaces", "namespaces.id = team_namespaces.namespace_id"). Join("LEFT", "team_namespaces", "namespaces.id = team_namespaces.namespace_id").
Join("LEFT", "team_members", "team_members.team_id = team_namespaces.team_id"). Join("LEFT", "team_members", "team_members.team_id = team_namespaces.team_id").
Where("team_members.user_id = ? AND team_namespaces.right = ?", user.ID, r). Where("namespaces.id = ? " +
Or("namespaces.owner_id = ?", user.ID). "AND ((team_members.user_id = ? AND team_namespaces.right = ?) " +
"OR namespaces.owner_id = ?)", n.ID, user.ID, r, user.ID).
Get(&Namespace{}) Get(&Namespace{})
if err != nil { if err != nil {