Update team rights to return the max right

This commit is contained in:
kolaente 2020-08-09 17:37:14 +02:00
parent a2d7ad04de
commit 7a7b0962ea
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 11 additions and 3 deletions

View File

@ -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
}