From 7a7b0962eaef7d9009d44ec4420f2821b750cc94 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 9 Aug 2020 17:37:14 +0200 Subject: [PATCH] Update team rights to return the max right --- pkg/models/teams_rights.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/models/teams_rights.go b/pkg/models/teams_rights.go index 0ba1ffd1f..0a926fa1d 100644 --- a/pkg/models/teams_rights.go +++ b/pkg/models/teams_rights.go @@ -60,9 +60,17 @@ func (t *Team) IsAdmin(a web.Auth) (bool, error) { } // CanRead returns true if the user has read access to the team -func (t *Team) CanRead(a web.Auth) (bool, error) { +func (t *Team) CanRead(a web.Auth) (bool, int, error) { // Check if the user is in the team - return x.Where("team_id = ?", t.ID). + tm := &TeamMember{} + can, err := x.Where("team_id = ?", t.ID). And("user_id = ?", a.GetID()). - Get(&TeamMember{}) + Get(tm) + + maxRights := 0 + if tm.Admin { + maxRights = int(RightAdmin) + } + + return can, maxRights, err }