Fixed task attachment rights check
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
kolaente 2019-10-13 17:33:23 +02:00
parent 70791f5c65
commit 7d6e6d49fd
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 18 additions and 5 deletions

View File

@ -20,18 +20,27 @@ import "code.vikunja.io/web"
// CanRead checks if the user can see an attachment
func (ta *TaskAttachment) CanRead(a web.Auth) (bool, error) {
t := Task{ID: ta.TaskID}
t, err := GetTaskByIDSimple(ta.TaskID)
if err != nil {
return false, err
}
return t.CanRead(a)
}
// CanDelete checks if the user can delete an attachment
func (ta *TaskAttachment) CanDelete(a web.Auth) (bool, error) {
t := Task{ID: ta.TaskID}
t, err := GetTaskByIDSimple(ta.TaskID)
if err != nil {
return false, err
}
return t.CanWrite(a)
}
// CanCreate checks if the user can create an attachment
func (ta *TaskAttachment) CanCreate(a web.Auth) (bool, error) {
t := Task{ID: ta.TaskID}
t, err := GetTaskByIDSimple(ta.TaskID)
if err != nil {
return false, err
}
return t.CanCreate(a)
}

View File

@ -99,8 +99,12 @@ func GetTaskAttachment(c echo.Context) error {
return handler.HandleHTTPError(err, c)
}
// Send the file to the client
taskAttachment.File.LoadFileByID()
// Open an send the file to the client
err = taskAttachment.File.LoadFileByID()
if err != nil {
return handler.HandleHTTPError(err, c)
}
http.ServeContent(c.Response(), c.Request(), taskAttachment.File.Name, taskAttachment.File.Created, taskAttachment.File.File)
return nil
}