feat: enable sharing with visitor

This commit is contained in:
hexxa 2021-09-24 14:15:19 +08:00 committed by Hexxa
parent d440cbe477
commit 2ccdf0e287
7 changed files with 73 additions and 48 deletions

View file

@ -540,11 +540,16 @@ func (h *FileHandlers) Download(c *gin.Context) {
c.JSON(q.ErrResp(c, 403, q.ErrAccessDenied))
return
}
userID := c.MustGet(q.UserIDParam).(string)
userIDInt, err := strconv.ParseUint(userID, 10, 64)
if err != nil {
c.JSON(q.ErrResp(c, 500, err))
return
var err error
userIDInt := userstore.VisitorID
if role != userstore.VisitorRole {
userID := c.MustGet(q.UserIDParam).(string)
userIDInt, err = strconv.ParseUint(userID, 10, 64)
if err != nil {
c.JSON(q.ErrResp(c, 500, err))
return
}
}
// TODO: when sharing is introduced, move following logics to a separeted method