Improve request validation.

This commit is contained in:
2025-05-13 19:10:41 +08:00
parent 12c1e0e413
commit cbac071dd2
7 changed files with 55 additions and 33 deletions

View File

@@ -12,7 +12,11 @@ func handleCreateTag(c fiber.Ctx) error {
if tag == "" {
return model.NewRequestError("name is required")
}
t, err := service.CreateTag(tag)
uid, ok := c.Locals("uid").(uint)
if !ok {
return model.NewUnAuthorizedError("You must be logged in to create a tag")
}
t, err := service.CreateTag(uid, tag)
if err != nil {
return err
}