authmiddleware fix

This commit is contained in:
Yared Yemane 2025-05-23 20:37:29 +03:00
parent 9dd566417e
commit 9793854596
5 changed files with 4 additions and 178 deletions

View File

@ -200,33 +200,6 @@ const docTemplate = `{
]
}
}
},
"400": {
"description": "Invalid request parameters",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal server error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
@ -465,42 +438,6 @@ const docTemplate = `{
]
}
}
},
"400": {
"description": "Invalid callback format",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"401": {
"description": "Invalid signature",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"409": {
"description": "Duplicate transaction",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal processing error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}

View File

@ -192,33 +192,6 @@
]
}
}
},
"400": {
"description": "Invalid request parameters",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal server error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
@ -457,42 +430,6 @@
]
}
}
},
"400": {
"description": "Invalid callback format",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"401": {
"description": "Invalid signature",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"409": {
"description": "Duplicate transaction",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal processing error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}

View File

@ -1440,24 +1440,6 @@ paths:
type: string
type: object
type: object
"400":
description: Invalid request parameters
schema:
additionalProperties:
type: string
type: object
"401":
description: Unauthorized
schema:
additionalProperties:
type: string
type: object
"500":
description: Internal server error
schema:
additionalProperties:
type: string
type: object
security:
- BearerAuth: []
summary: Launch an Alea Play virtual game
@ -1613,30 +1595,6 @@ paths:
type: string
type: object
type: object
"400":
description: Invalid callback format
schema:
additionalProperties:
type: string
type: object
"401":
description: Invalid signature
schema:
additionalProperties:
type: string
type: object
"409":
description: Duplicate transaction
schema:
additionalProperties:
type: string
type: object
"500":
description: Internal processing error
schema:
additionalProperties:
type: string
type: object
summary: Process Alea Play game callback
tags:
- Alea Virtual Games

View File

@ -16,12 +16,9 @@ import (
// @Param currency query string false "Currency code (ISO 4217)" Enums(USD, EUR, GBP) default(USD)
// @Param mode query string false "Game mode" Enums(real, demo) default(real)
// @Success 200 {object} map[string]string{launch_url=string} "Returns authenticated game launch URL"
// @Failure 400 {object} map[string]string "Invalid request parameters"
// @Failure 401 {object} map[string]string "Unauthorized"
// @Failure 500 {object} map[string]string "Internal server error"
// @Router /api/v1/alea-games/launch [get]
func (h *Handler) LaunchAleaGame(c *fiber.Ctx) error {
userID := c.Locals("userID").(int64)
userID := c.Locals("user_id").(int64)
gameID := c.Query("game_id")
currency := c.Query("currency", "USD")
mode := c.Query("mode", "real") // real or demo
@ -36,6 +33,7 @@ func (h *Handler) LaunchAleaGame(c *fiber.Ctx) error {
return c.JSON(fiber.Map{
"launch_url": launchURL,
"message": "Game launched successfully",
})
}
@ -47,10 +45,6 @@ func (h *Handler) LaunchAleaGame(c *fiber.Ctx) error {
// @Produce json
// @Param callback body domain.AleaPlayCallback true "Callback payload"
// @Success 200 {object} map[string]string{status=string} "Callback processed successfully"
// @Failure 400 {object} map[string]string "Invalid callback format"
// @Failure 401 {object} map[string]string "Invalid signature"
// @Failure 409 {object} map[string]string "Duplicate transaction"
// @Failure 500 {object} map[string]string "Internal processing error"
// @Router /api/v1/webhooks/alea [post]
func (h *Handler) HandleAleaCallback(c *fiber.Ctx) error {
var cb domain.AleaPlayCallback

View File

@ -174,8 +174,8 @@ func (a *App) initAppRoutes() {
a.fiber.Get("/api/v1/chapa/transfers/verify/:transfer_ref", h.VerifyTransfer)
//Alea Play Virtual Game Routes
a.fiber.Get("/api/v1/alea-games/launch", h.LaunchAleaGame)
a.fiber.Post("/api/v1/webhooks/alea", h.HandleAleaCallback)
a.fiber.Get("/api/v1/alea-games/launch", a.authMiddleware, h.LaunchAleaGame)
a.fiber.Post("/api/v1/webhooks/alea", a.authMiddleware, h.HandleAleaCallback)
// a.fiber.Post("/webhooks/alea", middleware.AleaWebhookMiddleware(a.cfg.AleaPlay.SecretKey), h.HandleAleaCallback)
// Transactions /transactions