1
0

Implemented CanUpdate method

This commit is contained in:
konrad
2018-07-12 23:07:03 +02:00
committed by kolaente
parent e3b996c383
commit 6fd2a97574
10 changed files with 54 additions and 70 deletions

View File

@ -20,25 +20,15 @@ func CreateOrUpdateList(list *List) (err error) {
}
// Update implements the update method of CRUDable
func (l *List) Update(id int64, doer *User) (err error) {
func (l *List) Update(id int64) (err error) {
l.ID = id
// Check if it exists
oldList, err := GetListByID(l.ID)
_, err = GetListByID(l.ID)
if err != nil {
return
}
// Check rights
user, _, err := GetUserByID(doer.ID)
if err != nil {
return
}
if !oldList.IsAdmin(&user) {
return ErrNeedToBeListAdmin{ListID: id, UserID: user.ID}
}
return CreateOrUpdateList(l)
}