Skip to content

Commit

Permalink
fix trashbin dav api for ocis (#1326)
Browse files Browse the repository at this point in the history
The dav api now expects username instead of userid.

Fixes owncloud/ocis#863
  • Loading branch information
C0rby authored Nov 20, 2020
1 parent d44fe05 commit f5afafc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/fix-ocis-trashbin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: fix dav api for trashbin

The api was comparing the requested username to the userid.


https://github.com/owncloud/ocis/issues/863

12 changes: 6 additions & 6 deletions internal/http/services/owncloud/ocdav/trashbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler {
return
}

var userid string
userid, r.URL.Path = router.ShiftPath(r.URL.Path)
var username string
username, r.URL.Path = router.ShiftPath(r.URL.Path)

if userid == "" {
if username == "" {
// listing is disabled, no auth will change that
w.WriteHeader(http.StatusMethodNotAllowed)
return
Expand All @@ -74,8 +74,8 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler {
w.WriteHeader(http.StatusBadRequest)
return
}
if u.Id.OpaqueId != userid {
log.Debug().Str("userid", userid).Interface("user", u).Msg("trying to read another users trash")
if u.Username != username {
log.Debug().Str("username", username).Interface("user", u).Msg("trying to read another users trash")
// listing other users trash is forbidden, no auth will change that
w.WriteHeader(http.StatusMethodNotAllowed)
return
Expand All @@ -98,7 +98,7 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler {
if key != "" && r.Method == "MOVE" {
// find path in url relative to trash base
trashBase := ctx.Value(ctxKeyBaseURI).(string)
baseURI := path.Join(path.Dir(trashBase), "files", userid)
baseURI := path.Join(path.Dir(trashBase), "files", username)
ctx = context.WithValue(ctx, ctxKeyBaseURI, baseURI)
r = r.WithContext(ctx)

Expand Down

0 comments on commit f5afafc

Please sign in to comment.