|
@@ -33,19 +33,23 @@ func (a *AuthController) Login(c *gin.Context) {
|
|
|
resp.Fail("邮箱或手机号错误", c)
|
|
|
return
|
|
|
}
|
|
|
- sysUser, err := english_report_email.CheckUser(req.Type, req.Account, req.Password)
|
|
|
+ sysUser, err := english_report_email.CheckUserPwd(req.Type, req.Account, req.Password)
|
|
|
if err != nil {
|
|
|
- resp.FailData("登录失败,账号或密码错误", "Err:"+err.Error(), c)
|
|
|
+ resp.FailData("Login failed. Please check your entries and try again.", "Err:"+err.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
if sysUser == nil {
|
|
|
- resp.FailData("登录失败,账号或密码错误", "Err:"+err.Error(), c)
|
|
|
+ resp.FailData("Login failed. Please check your entries and try again.", "Err:"+err.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
if sysUser.Enable == 0 {
|
|
|
resp.FailData("您的账号已被禁用,如需登录,请联系管理员", "Err:"+err.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
+ if sysUser.Status == 3 {
|
|
|
+ resp.FailData("Your trial has ended</br>Enjoyed your experience with us?</br>Contact us at stephanie@hzinsights.com to extend your trial.", "Err:"+err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
account := utils.MD5(req.Account)
|
|
|
token, err := utils.GenToken(account)
|
|
|
sysSession := new(session.EnglishYbSession)
|
|
@@ -94,12 +98,40 @@ func (a *AuthController) Register(c *gin.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ emailItem, err := english_report_email.CheckUser(req.Email)
|
|
|
+ if err != nil && err != utils.ErrNoRow{
|
|
|
+ resp.Fail("验证码错误,请重新输入", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if emailItem != nil{
|
|
|
+ if emailItem.Status == 1{
|
|
|
+ //已经是正式用户,更新密码即可
|
|
|
+ emailItem.Password = req.Password
|
|
|
+ emailItem.ModifyTime = time.Now()
|
|
|
+
|
|
|
+ err = emailItem.Update([]string{"Password","ModifyTime"})
|
|
|
+ if err != nil {
|
|
|
+ resp.FailMsg("修改密码失败", "修改密码失败,Err:"+err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.Ok("注册成功", c)
|
|
|
+ } else if emailItem.Status == 2{
|
|
|
+ resp.Fail("There is already a user account associated with this email address. Please log in instead.", c)
|
|
|
+ return
|
|
|
+ } else if emailItem.Status == 3 {
|
|
|
+ resp.Fail("Your trial has ended</br>Enjoyed your experience with us?</br>Contact us at stephanie@hzinsights.com to extend your trial.", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //状态为临时
|
|
|
user := english_report_email.Email{
|
|
|
Name: req.Name,
|
|
|
CompanyName: req.CompanyName,
|
|
|
Email: req.Email,
|
|
|
Password: req.Password,
|
|
|
Enable: 1,
|
|
|
+ Status: 2,
|
|
|
}
|
|
|
user.Set()
|
|
|
|