Skip to content

Commit 150d241

Browse files
committed
fix forgot to bind the request
1 parent c01e526 commit 150d241

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pkg/controller/auth.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,25 @@ func VerifyOTP(c echo.Context) error {
347347

348348
func ResendOTP(c echo.Context) error {
349349
ctx := c.Request().Context()
350+
350351
var req models.ResendOTP
352+
if err := c.Bind(&req); err != nil {
353+
logger.Errorf(logger.InternalError, err.Error())
354+
return c.JSON(http.StatusBadRequest, &models.Response{
355+
Status: "fail",
356+
Message: "Invalid request body",
357+
})
358+
}
359+
360+
if err := utils.Validate.Struct(req); err != nil {
361+
logger.Errorf(logger.InternalError, err.Error())
362+
return c.JSON(http.StatusBadRequest, &models.Response{
363+
Status: "fail",
364+
Message: "Validation errors",
365+
Data: utils.FormatValidationErrors(err),
366+
})
367+
}
368+
351369
err := utils.GenerateOTP(ctx, req.Email)
352370
if err != nil {
353371
logger.Errorf(logger.InternalError, err.Error())

0 commit comments

Comments
 (0)