fix: issues
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -26,6 +26,9 @@ func (c *Controller) List(ctx fiber.Ctx) error {
|
||||
func (c *Controller) Charge(ctx fiber.Ctx) error {
|
||||
claim := fiber.Locals[*jwt.Claims](ctx, consts.CtxKeyClaim)
|
||||
log.Debug(claim)
|
||||
if claim == nil {
|
||||
return errorx.RequestUnAuthorized
|
||||
}
|
||||
|
||||
// [tenantId, chargeAmount, timestamp]
|
||||
code := ctx.Params("code")
|
||||
@@ -41,6 +44,10 @@ func (c *Controller) Info(ctx fiber.Ctx) error {
|
||||
claim := fiber.Locals[*jwt.Claims](ctx, consts.CtxKeyClaim)
|
||||
log.Debug(claim)
|
||||
|
||||
if claim == nil {
|
||||
return errorx.RequestUnAuthorized
|
||||
}
|
||||
|
||||
info := &UserInfo{}
|
||||
|
||||
balance, err := c.svc.GetTenantUserBalance(ctx.Context(), claim.TenantID, claim.UserID)
|
||||
@@ -62,6 +69,9 @@ func (c *Controller) Info(ctx fiber.Ctx) error {
|
||||
func (c *Controller) GetChargeCodes(ctx fiber.Ctx) error {
|
||||
claim := fiber.Locals[*jwt.Claims](ctx, consts.CtxKeyClaim)
|
||||
log.Debug(claim)
|
||||
if claim == nil {
|
||||
return errorx.RequestUnAuthorized
|
||||
}
|
||||
|
||||
tenant, err := c.svc.GetTenantByID(ctx.Context(), claim.TenantID)
|
||||
if err != nil {
|
||||
@@ -98,6 +108,9 @@ func (c *Controller) GetChargeCodes(ctx fiber.Ctx) error {
|
||||
func (c *Controller) BalanceHistory(ctx fiber.Ctx) error {
|
||||
claim := fiber.Locals[*jwt.Claims](ctx, consts.CtxKeyClaim)
|
||||
log.Debug(claim)
|
||||
if claim == nil {
|
||||
return errorx.RequestUnAuthorized
|
||||
}
|
||||
|
||||
histories, err := c.svc.GetBalanceHistory(ctx.Context(), claim.TenantID, claim.UserID)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user