1
0

Fix link share creation & creating admin link shares without admin rights

This commit is contained in:
kolaente
2020-04-27 11:42:41 +02:00
parent 711124f5c0
commit 56dbb564ea
3 changed files with 93 additions and 2 deletions

View File

@ -99,10 +99,16 @@ func GetLinkShareFromClaims(claims jwt.MapClaims) (share *LinkSharing, err error
// @Failure 500 {object} models.Message "Internal error"
// @Router /lists/{list}/shares [put]
func (share *LinkSharing) Create(a web.Auth) (err error) {
err = share.Right.isValid()
if err != nil {
return
}
share.SharedByID = a.GetID()
share.Hash = utils.MakeRandomString(40)
_, err = x.Insert(share)
share.SharedBy, _ = a.(*user.User)
share.SharedBy, _ = user.GetFromAuth(a)
return
}

View File

@ -53,9 +53,16 @@ func (share *LinkSharing) canDoLinkShare(a web.Auth) (bool, error) {
return false, nil
}
l, err := GetListSimplByTaskID(share.ListID)
l := &List{ID: share.ListID}
err := l.GetSimpleByID()
if err != nil {
return false, err
}
// Check if the user is admin when the link right is admin
if share.Right == RightAdmin {
return l.IsAdmin(a)
}
return l.CanWrite(a)
}