ziwen 1 年之前
父节点
当前提交
6e6633eff7
共有 2 个文件被更改,包括 18 次插入9 次删除
  1. 13 9
      controller/auth.go
  2. 5 0
      utils/constants.go

+ 13 - 9
controller/auth.go

@@ -58,7 +58,8 @@ func (a *AuthController) Login(c *gin.Context) {
 		}
 	}
 
-	sysUser, err := english_report_email.CheckUserPwd(req.Type, req.CountryCode, req.Account, req.Password)
+	password := utils.MD5(req.Password+utils.KEY)
+	sysUser, err := english_report_email.CheckUserPwd(req.Type, req.CountryCode, req.Account, password)
 	if err != nil {
 		resp.FailData("Login failed. Please check your entries and try again.", "Err:"+err.Error(), c)
 		return
@@ -68,7 +69,7 @@ func (a *AuthController) Login(c *gin.Context) {
 		return
 	}
 	if sysUser.Enable == 0 {
-		resp.Fail("您的账号已被禁用,如需登录,请联系管理员", c)
+		resp.Fail("Your account has been disabled, please contact stephanie@hzinsights.com", c)
 		return
 	}
 	if sysUser.Status == 3 {
@@ -133,10 +134,11 @@ func (a *AuthController) Register(c *gin.Context) {
 		resp.Fail("验证码错误,请重新输入", c)
 		return
 	}
+	password := utils.MD5(req.Password+utils.KEY)
 	if emailItem != nil {
 		if emailItem.Status == 1 && emailItem.Password == "" {
 			//已经是正式用户,更新密码即可
-			emailItem.Password = req.Password
+			emailItem.Password = password
 			emailItem.ModifyTime = time.Now()
 
 			err = emailItem.Update([]string{"Password", "ModifyTime"})
@@ -159,7 +161,7 @@ func (a *AuthController) Register(c *gin.Context) {
 		Name:        req.Name,
 		CompanyName: req.CompanyName,
 		Email:       req.Email,
-		Password:    req.Password,
+		Password:    password,
 		Enable:      1,
 		Status:      2,
 	}
@@ -230,9 +232,10 @@ func (a *AuthController) ModifyPwd(c *gin.Context) {
 		return
 	}
 
+	password := utils.MD5(req.NewPwd+utils.KEY)
 	emailitem := english_report_email.Email{
 		Id:       userinfo.Id,
-		Password: req.NewPwd,
+		Password: password,
 	}
 	emailitem.ModifyTime = time.Now()
 
@@ -451,9 +454,10 @@ func (a *AuthController) ForgetPwd(c *gin.Context) {
 		return
 	}
 
+	password := utils.MD5(req.Password+utils.KEY)
 	emailitem := english_report_email.Email{
 		Id:       userEmail.Id,
-		Password: req.Password,
+		Password: password,
 	}
 	emailitem.ModifyTime = time.Now()
 
@@ -481,17 +485,17 @@ func (a *AuthController) ModifyMobile(c *gin.Context) {
 	userinfo := services.GetInfoByClaims(c)
 
 	if req.NewMobile == "" {
-		resp.Fail("Please enter your phone number", c)
+		resp.Fail("Please enter a new phone number", c)
 		return
 	}
 
 	if req.OldMobile == "" {
-		resp.Fail("Please enter the original password", c)
+		resp.Fail("Please enter the original phone number", c)
 		return
 	}
 
 	if req.OldMobile != userinfo.Mobile {
-		resp.Fail("The old password is wrong, please re-enter.", c)
+		resp.Fail("The old phone number is wrong, please re-enter.", c)
 		return
 	}
 

+ 5 - 0
utils/constants.go

@@ -52,4 +52,9 @@ var (
 
 	JhGnAppKey = "4c8504c49dd335e99cfd7b6a3a9e2415" //聚合国内AppKey
 	JhGjAppKey = "3326ad2c1047a4cd92ace153e6044ca3"
+)
+
+// 加密key
+const (
+	KEY = "wdO40P8eCNXEqZbX44pcl9tN"
 )