From ba195f5a8baf50aa70da5fd742f5105f2ecec9ec Mon Sep 17 00:00:00 2001 From: analogpvt <72215823+analogpvt@users.noreply.github.com> Date: Fri, 19 May 2023 22:52:46 +0530 Subject: [PATCH] Update misc.go --- controller/misc.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/controller/misc.go b/controller/misc.go index d200a239..89d6705d 100644 --- a/controller/misc.go +++ b/controller/misc.go @@ -71,23 +71,23 @@ func SendEmailVerification(c *gin.Context) { if err := common.Validate.Var(email, "required,email"); err != nil { c.JSON(http.StatusOK, gin.H{ "success": false, - "message": "无效的参数", + "message": "invalid parameter", }) return } if model.IsEmailAlreadyTaken(email) { c.JSON(http.StatusOK, gin.H{ "success": false, - "message": "邮箱地址已被占用", + "message": "Email address already taken", }) return } code := common.GenerateVerificationCode(6) common.RegisterVerificationCodeWithKey(email, code, common.EmailVerificationPurpose) - subject := fmt.Sprintf("%s邮箱验证邮件", common.SystemName) - content := fmt.Sprintf("

您好,你正在进行%s邮箱验证。

"+ - "

您的验证码为: %s

"+ - "

验证码 %d 分钟内有效,如果不是本人操作,请忽略。

", common.SystemName, code, common.VerificationValidMinutes) + subject := fmt.Sprintf("%sEmail verification email", common.SystemName) + content := fmt.Sprintf("

Hello, you are verifying your %s email address。

"+ + "

Your verification code is: %s

"+ + "

The verification code is valid within %d minutes, if it is not operated by me, please ignore it。

", common.SystemName, code, common.VerificationValidMinutes) err := common.SendEmail(subject, email, content) if err != nil { c.JSON(http.StatusOK, gin.H{ @@ -108,24 +108,24 @@ func SendPasswordResetEmail(c *gin.Context) { if err := common.Validate.Var(email, "required,email"); err != nil { c.JSON(http.StatusOK, gin.H{ "success": false, - "message": "无效的参数", + "message": "invalid parameter", }) return } if !model.IsEmailAlreadyTaken(email) { c.JSON(http.StatusOK, gin.H{ "success": false, - "message": "该邮箱地址未注册", + "message": "This email address is not registered", }) return } code := common.GenerateVerificationCode(0) common.RegisterVerificationCodeWithKey(email, code, common.PasswordResetPurpose) link := fmt.Sprintf("%s/user/reset?email=%s&token=%s", common.ServerAddress, email, code) - subject := fmt.Sprintf("%s密码重置", common.SystemName) - content := fmt.Sprintf("

您好,你正在进行%s密码重置。

"+ - "

点击此处进行密码重置。

"+ - "

重置链接 %d 分钟内有效,如果不是本人操作,请忽略。

", common.SystemName, link, common.VerificationValidMinutes) + subject := fmt.Sprintf("%sPassword reset", common.SystemName) + content := fmt.Sprintf("

Hello, you are in the process of %s password reset。

"+ + "

Click here to reset password。

"+ + "

The reset link will be valid within %d minutes, if it is not done by me, please ignore it。

", common.SystemName, link, common.VerificationValidMinutes) err := common.SendEmail(subject, email, content) if err != nil { c.JSON(http.StatusOK, gin.H{ @@ -152,14 +152,14 @@ func ResetPassword(c *gin.Context) { if req.Email == "" || req.Token == "" { c.JSON(http.StatusOK, gin.H{ "success": false, - "message": "无效的参数", + "message": "invalid parameter", }) return } if !common.VerifyCodeWithKey(req.Email, req.Token, common.PasswordResetPurpose) { c.JSON(http.StatusOK, gin.H{ "success": false, - "message": "重置链接非法或已过期", + "message": "The reset link is illegal or has expired", }) return }