UPDATE: Fix bug
All checks were successful
Build and Release / release (push) Successful in 1m1s

This commit is contained in:
2026-04-08 14:23:17 +07:00
parent 9209d9fb22
commit 4706d4ea81
4 changed files with 63 additions and 6 deletions

View File

@@ -260,7 +260,23 @@ func (h *UserController) ChangeRoleUser(c fiber.Ctx) error {
Message: err.Error(),
})
}
user, err := h.service.ChangeRoleUser(ctx, dto)
claimsVal := c.Locals("user_claims")
if claimsVal == nil {
return c.Status(fiber.StatusUnauthorized).JSON(response.CommonResponse{
Status: false,
Message: "Unauthorized",
})
}
claims, ok := claimsVal.(*response.JWTClaims)
if !ok {
return c.Status(fiber.StatusUnauthorized).JSON(response.CommonResponse{
Status: false,
Message: "Invalid user claims",
})
}
user, err := h.service.ChangeRoleUser(ctx, claims, dto)
if err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
Status: false,