feat: add middleware to kyc route

This commit is contained in:
2025-09-16 11:35:36 +03:30
parent 7a365f57ec
commit f0914bcad9
6 changed files with 50 additions and 43 deletions
+6 -4
View File
@@ -2,6 +2,7 @@ package http
import (
"backend/internal/api/dto"
"backend/internal/api/http/middlewares"
"backend/internal/usecase"
"github.com/gofiber/fiber/v2"
@@ -160,7 +161,7 @@ func (h *AuthHandler) VerifyOTP(c *fiber.Ctx) error {
// @Accept json
// @Produce json
// @Param request body dto.KYCVerifyRequest true "KYC Verify Request"
// @Success 200 {object} dto.KYCVerifyResponse
// @Success 200 {object} dto.APIResponse
// @Failure 400 {object} map[string]string
// @Failure 500 {object} map[string]string
// @Router /auth/kyc [post]
@@ -171,15 +172,16 @@ func (h *AuthHandler) VerifyKYC(c *fiber.Ctx) error {
"error": "invalid request body",
})
}
err := h.authService.VerifyKYC(c.Context(), req.UserID, req.NationalID, req.BirthDate)
claims := middlewares.GetUserClaims(c)
err := h.authService.VerifyKYC(c.Context(), claims.UserID, req.NationalID, req.BirthDate)
if err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
"error": err.Error(),
})
}
return c.Status(fiber.StatusOK).JSON(dto.KYCVerifyResponse{
return c.Status(fiber.StatusOK).JSON(dto.APIResponse{
Success: true,
Message: "KYC verified successfully",
})
}