File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -345,6 +345,25 @@ func VerifyOTP(c echo.Context) error {
345345 })
346346}
347347
348+ func ResendOTP (c echo.Context ) error {
349+ ctx := c .Request ().Context ()
350+ var req models.ResendOTP
351+ err := utils .GenerateOTP (ctx , req .Email )
352+ if err != nil {
353+ logger .Errorf (logger .InternalError , err .Error ())
354+
355+ return c .JSON (http .StatusInternalServerError , & models.Response {
356+ Status : "fail" ,
357+ Message : "Failed to generate OTP" ,
358+ })
359+ }
360+
361+ return c .JSON (http .StatusOK , & models.Response {
362+ Status : "success" ,
363+ Message : "OTP has been sent to email" ,
364+ })
365+ }
366+
348367func Login (c echo.Context ) error {
349368 ctx := c .Request ().Context ()
350369 var req models.LoginRequest
Original file line number Diff line number Diff line change @@ -31,3 +31,7 @@ type UpdatePasswordRequest struct {
3131 NewPassword string `json:"new_password" validate:"required"`
3232 OTP string `json:"otp" validate:"required"`
3333}
34+
35+ type ResendOTP struct {
36+ Email string `json:"email"`
37+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ func AuthRoutes(incomingRoutes *echo.Group) {
1818 auth .GET ("/star" , controller .CheckStarred , middleware .JWTMiddleware ())
1919 auth .POST ("/github" , controller .UpdateGithubProfile , middleware .JWTMiddleware ())
2020 auth .POST ("/logout" , controller .Logout )
21+ auth .POST ("/resend-otp" , controller .ResendOTP )
2122
2223 // auth.Use(middleware.JWTMiddleware())
2324 // auth.GET("/ping", controller.Ping)
You can’t perform that action at this time.
0 commit comments