Return rights when reading a single item (#626)
Fix lint Update docs Fix loading all rights (list & namespace) Add tests Update web framework Make tests run again Update all calls to CanRead methods Update task attachment & task comment & task rights to return the max right Update team rights to return the max right Update namespace rights to return the max right Update list rights to return the max right Update link share rights to return the max right Update label rights to return the max right Update web dependency Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/626
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user