test(auth): add permission tests for files and settings api

This commit is contained in:
hexxa 2022-02-23 11:40:51 +08:00 committed by Hexxa
parent cff87bdddd
commit d2d269171d
5 changed files with 404 additions and 317 deletions

View file

@ -992,6 +992,11 @@ func (h *FileHandlers) GenerateHash(c *gin.Context) {
return
}
if req.FilePath == "" {
c.JSON(q.ErrResp(c, 400, errors.New("invalid file path")))
return
}
role := c.MustGet(q.RoleParam).(string)
userName := c.MustGet(q.UserParam).(string)
if !h.canAccess(userName, role, "hash.gen", req.FilePath) {