fix: issues

This commit is contained in:
Rogee
2024-12-19 10:22:25 +08:00
parent db05ee4265
commit 32b8efe5ad
4 changed files with 28 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package medias
import (
"backend/pkg/consts"
"backend/pkg/errorx"
"backend/pkg/pg"
"backend/providers/jwt"
@@ -48,6 +49,9 @@ func (c *Controller) Show(ctx fiber.Ctx) error {
hash := ctx.Params("hash")
claim := fiber.Locals[*jwt.Claims](ctx, consts.CtxKeyClaim)
log.Debug(claim)
if claim == nil {
return errorx.RequestUnAuthorized
}
model, err := c.svc.GetMediaByHash(ctx.Context(), claim.TenantID, hash)
if err != nil {
@@ -75,6 +79,9 @@ func (c *Controller) MediaIndex(ctx fiber.Ctx) error {
hash := ctx.Params("hash")
claim := fiber.Locals[*jwt.Claims](ctx, consts.CtxKeyClaim)
log.Debug(claim)
if claim == nil {
return errorx.RequestUnAuthorized
}
model, err := c.svc.GetMediaByHash(ctx.Context(), claim.TenantID, hash)
if err != nil {
@@ -113,6 +120,9 @@ func (c *Controller) MediaSegment(ctx fiber.Ctx) error {
hash := ctx.Params("hash")
claim := fiber.Locals[*jwt.Claims](ctx, consts.CtxKeyClaim)
log.Debug(claim)
if claim == nil {
return errorx.RequestUnAuthorized
}
model, err := c.svc.GetMediaByHash(ctx.Context(), claim.TenantID, hash)
if err != nil {
@@ -129,6 +139,9 @@ func (c *Controller) Checkout(ctx fiber.Ctx) error {
hash := ctx.Params("hash")
claim := fiber.Locals[*jwt.Claims](ctx, consts.CtxKeyClaim)
log.Debug(claim)
if claim == nil {
return errorx.RequestUnAuthorized
}
model, err := c.svc.GetMediaByHash(ctx.Context(), claim.TenantID, hash)
if err != nil {