1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-23 15:19:42 +02:00

Add diagnostic output for attachment download

This commit is contained in:
McMatts 2019-03-13 11:42:32 +00:00
parent f4a371357e
commit 1854998c80

View file

@ -67,7 +67,7 @@ func (h *Handler) Download(w http.ResponseWriter, r *http.Request) {
// Get attachment being requested.
a, err := h.Store.Attachment.GetAttachment(ctx, ctx.OrgID, request.Param(r, "attachmentID"))
if err == sql.ErrNoRows {
response.WriteNotFoundError(w, method, request.Param(r, "fileID"))
response.WriteNotFoundError(w, method, request.Param(r, "attachmentID"))
return
}
if err != nil {
@ -161,6 +161,12 @@ func (h *Handler) Download(w http.ResponseWriter, r *http.Request) {
canDownload = true
}
if len(secureToken) == 0 && len(authToken) == 0 {
h.Runtime.Log.Error("get attachment received no access token", err)
response.WriteForbiddenError(w)
return
}
// Send back error if caller unable view attachment
if !canDownload {
h.Runtime.Log.Error("get attachment refused", err)