|
@@ -164,8 +164,8 @@ func (this *UserCommonController) Login() {
|
|
|
itemsSession.AccessToken = token
|
|
|
itemsSession.CreatedTime = time.Now()
|
|
|
itemsSession.LastUpdatedTime = time.Now()
|
|
|
- itemsSession.ExpireTime = time.Now().AddDate(0, 3, 0)
|
|
|
- err = models.AddCygxMfyxWebSession(itemsSession)
|
|
|
+ itemsSession.ExpireTime = time.Now().AddDate(0, 0, 30)
|
|
|
+ err = services.HandleCygxMfyxWebSession(itemsSession)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取用户信息失败"
|
|
|
br.ErrMsg = "添加Token失败,Err:" + err.Error()
|
|
@@ -2083,3 +2083,114 @@ func (this *UserController) UpdatePass() {
|
|
|
br.Success = true
|
|
|
br.Msg = "操作成功"
|
|
|
}
|
|
|
+
|
|
|
+// @Title 重置密码接口(忘记密码)
|
|
|
+// @Description 设置密码接口
|
|
|
+// @Param request body models.SetUserPasswordReq true "type json string"
|
|
|
+// @Success 200 {object} models.LoginResp
|
|
|
+// @router /reset_pass [post]
|
|
|
+func (this *UserCommonController) ReSetPass() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ var req models.SetUserPasswordReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mobile := req.Mobile
|
|
|
+ mobile = strings.Trim(mobile, " ")
|
|
|
+ if mobile == "" {
|
|
|
+ br.Msg = "参数错误"
|
|
|
+ br.ErrMsg = "参数错误,手机号为空"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ code := req.VCode
|
|
|
+ if code == "" {
|
|
|
+ br.Msg = "参数错误"
|
|
|
+ br.ErrMsg = "Code 为空"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ password := req.Password
|
|
|
+ if password == "" {
|
|
|
+ br.Msg = "参数错误"
|
|
|
+ br.ErrMsg = "Password 为空"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ item, err := models.GetMsgCode(req.Mobile, req.VCode)
|
|
|
+ if err != nil {
|
|
|
+ if err.Error() == utils.ErrNoRow() {
|
|
|
+ br.Msg = "验证码错误,请重新输入"
|
|
|
+ br.ErrMsg = "校验验证码失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ br.Msg = "验证码错误,请重新输入"
|
|
|
+ br.ErrMsg = "校验验证码失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if item == nil {
|
|
|
+ br.Msg = "验证码错误,请重新输入"
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ user, err := models.GetWxUserItemByUserMobile(mobile)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ specialAuthorCheck := services.GetYanxuanSpecialAuthorInfo(user) //用户是否没开通研选专栏以及,专栏信息是否完善
|
|
|
+ if !specialAuthorCheck.IsAuthor {
|
|
|
+ br.Msg = "该账号不是专栏作者,请使用验证码登录。"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ isSetPassword := services.GetIsSetPassword(mobile)
|
|
|
+ if isSetPassword {
|
|
|
+ err = models.UpdateCygxUserPassword(mobile, password)
|
|
|
+ } else {
|
|
|
+ itemps := new(models.CygxUserPassword)
|
|
|
+ itemps.UserId = user.UserId
|
|
|
+ itemps.Mobile = mobile
|
|
|
+ itemps.RealName = user.RealName
|
|
|
+ itemps.Password = password
|
|
|
+ itemps.CreateTime = time.Now()
|
|
|
+ itemps.ModifyTime = time.Now()
|
|
|
+ err = models.AddCygxUserPassword(itemps)
|
|
|
+ }
|
|
|
+ var token string
|
|
|
+ timeUnix := time.Now().Unix()
|
|
|
+ timeUnixStr := strconv.FormatInt(timeUnix, 10)
|
|
|
+ token = utils.MD5(mobile) + utils.MD5(timeUnixStr)
|
|
|
+ itemsSession := new(models.CygxMfyxWebSession)
|
|
|
+ itemsSession.UserId = user.UserId
|
|
|
+ itemsSession.Mobile = mobile
|
|
|
+ itemsSession.AccessToken = token
|
|
|
+ itemsSession.CreatedTime = time.Now()
|
|
|
+ itemsSession.LastUpdatedTime = time.Now()
|
|
|
+ itemsSession.ExpireTime = time.Now().AddDate(0, 0, 30)
|
|
|
+ err = services.HandleCygxMfyxWebSession(itemsSession)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取用户信息失败"
|
|
|
+ br.ErrMsg = "添加Token失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := new(models.LoginResp)
|
|
|
+ resp.UserId = user.UserId
|
|
|
+ resp.Headimgurl = user.Headimgurl
|
|
|
+ resp.Mobile = user.Mobile
|
|
|
+ resp.Email = user.Email
|
|
|
+ resp.CompanyName = user.CompanyName
|
|
|
+ resp.Authorization = token
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|