Update wechat.go

This commit is contained in:
analogpvt 2023-05-19 23:13:11 +05:30 committed by GitHub
parent 87a54f52c9
commit 3c22280bc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,7 +20,7 @@ type wechatLoginResponse struct {
func getWeChatIdByCode(code string) (string, error) { func getWeChatIdByCode(code string) (string, error) {
if code == "" { if code == "" {
return "", errors.New("无效的参数") return "", errors.New("Invalid parameter.")
} }
req, err := http.NewRequest("GET", fmt.Sprintf("%s/api/wechat/user?code=%s", common.WeChatServerAddress, code), nil) req, err := http.NewRequest("GET", fmt.Sprintf("%s/api/wechat/user?code=%s", common.WeChatServerAddress, code), nil)
if err != nil { if err != nil {
@ -44,7 +44,7 @@ func getWeChatIdByCode(code string) (string, error) {
return "", errors.New(res.Message) return "", errors.New(res.Message)
} }
if res.Data == "" { if res.Data == "" {
return "", errors.New("验证码错误或已过期") return "", errors.New("Invalid or expired verification code.")
} }
return res.Data, nil return res.Data, nil
} }
@ -52,7 +52,7 @@ func getWeChatIdByCode(code string) (string, error) {
func WeChatAuth(c *gin.Context) { func WeChatAuth(c *gin.Context) {
if !common.WeChatAuthEnabled { if !common.WeChatAuthEnabled {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"message": "管理员未开启通过微信登录以及注册", "message": "WeChat login and registration are not enabled by the administrator.",
"success": false, "success": false,
}) })
return return
@ -95,7 +95,7 @@ func WeChatAuth(c *gin.Context) {
} else { } else {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"success": false, "success": false,
"message": "管理员关闭了新用户注册", "message": "New user registration is disabled by the administrator.",
}) })
return return
} }
@ -103,7 +103,7 @@ func WeChatAuth(c *gin.Context) {
if user.Status != common.UserStatusEnabled { if user.Status != common.UserStatusEnabled {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"message": "用户已被封禁", "message": "User has been banned.",
"success": false, "success": false,
}) })
return return
@ -114,7 +114,7 @@ func WeChatAuth(c *gin.Context) {
func WeChatBind(c *gin.Context) { func WeChatBind(c *gin.Context) {
if !common.WeChatAuthEnabled { if !common.WeChatAuthEnabled {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"message": "管理员未开启通过微信登录以及注册", "message": "WeChat login and registration have not been enabled by the administrator.",
"success": false, "success": false,
}) })
return return
@ -131,7 +131,7 @@ func WeChatBind(c *gin.Context) {
if model.IsWeChatIdAlreadyTaken(wechatId) { if model.IsWeChatIdAlreadyTaken(wechatId) {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"success": false, "success": false,
"message": "该微信账号已被绑定", "message": "This WeChat account has already been bound.",
}) })
return return
} }