Added check to only let a user delete his own list
This commit is contained in:
@ -1,13 +1,17 @@
|
||||
package models
|
||||
|
||||
func DeleteListByID(listID int64) (err error) {
|
||||
func DeleteListByID(listID int64, doer *User) (err error) {
|
||||
|
||||
// Check if the list exists
|
||||
_, err = GetListByID(listID)
|
||||
list, err := GetListByID(listID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if list.Owner.ID != doer.ID {
|
||||
return ErrNeedToBeListOwner{ListID:listID, UserID:doer.ID}
|
||||
}
|
||||
|
||||
// Delete the list
|
||||
_, err = x.ID(listID).Delete(&List{})
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user