From d801092c7bd7e56905f47e74726f3bcbb344f7ba Mon Sep 17 00:00:00 2001 From: codermuss Date: Sun, 4 Aug 2024 11:35:44 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20remove=20html=20flows=20on=20verify?= =?UTF-8?q?=20email?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/server.go | 1 - api/verify_email.go | 30 +++++++++++++++--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/api/server.go b/api/server.go index 2709bc5..2f93e5a 100644 --- a/api/server.go +++ b/api/server.go @@ -40,7 +40,6 @@ func (server *Server) setupRouter() { router.Use(ZerologMiddleware()) router.Use(gin.Recovery()) - router.LoadHTMLGlob("/Users/mustafayilmaz/Go/projects/musarchive/templates/*") // Serve the API endpoints api := router.Group("/v1") diff --git a/api/verify_email.go b/api/verify_email.go index 7749280..c3067c3 100644 --- a/api/verify_email.go +++ b/api/verify_email.go @@ -2,7 +2,6 @@ package api import ( "net/http" - "time" "github.com/gin-gonic/gin" db "github.com/mustafayilmazdev/musarchive/db/sqlc" @@ -34,22 +33,23 @@ func (server *Server) VerifyEmail(ctx *gin.Context) { }) if err != nil { - data := gin.H{ - "Title": server.lm.Translate(req.Locale, localization.User_VerifyEmailErrorTitle), - "Timestamp": time.Now().Format(time.RFC1123), - "Content": server.lm.Translate(req.Locale, localization.Errors_AnErrorOccured), - "ErrorMessage": err, - } - ctx.HTML(http.StatusOK, "error_verify_email.html", data) + BuildResponse(ctx, BaseResponse{ + Code: http.StatusInternalServerError, + Message: ResponseMessage{ + Type: ERROR, + Content: err.Error(), + }, + }) + return } - data := gin.H{ - "Title": server.lm.Translate(req.Locale, localization.User_VerifyEmailSuccessTitle), - "Timestamp": time.Now().Format(time.RFC1123), - "Content": server.lm.Translate(req.Locale, localization.User_VerifyEmailSuccess), - "WelcomeMessage": server.lm.Translate(req.Locale, localization.User_VerifyEmailMessage), - } - ctx.HTML(http.StatusOK, "success_verify_email.html", data) + BuildResponse(ctx, BaseResponse{ + Code: http.StatusOK, + Message: ResponseMessage{ + Type: SUCCESS, + Content: server.lm.Translate(req.Locale, localization.User_VerifyEmailMessage), + }, + }) }