作者 yangfu

user auth fix

@@ -22,6 +22,7 @@ var errmessge ErrorMap = map[int]string{ @@ -22,6 +22,7 @@ var errmessge ErrorMap = map[int]string{
22 2027: "密码必须至少有6个字符", 22 2027: "密码必须至少有6个字符",
23 2028: "请输入正确的旧密码", 23 2028: "请输入正确的旧密码",
24 2029: "当前手机号已存在,请重新输入", 24 2029: "当前手机号已存在,请重新输入",
  25 + 2030: "新密码与旧密码一致,请重新输入",
25 2060: "读取公告失败", 26 2060: "读取公告失败",
26 4139: "authCode无效或过期", 27 4139: "authCode无效或过期",
27 4140: "refreshToken过期,需要重新登录授权", 28 4140: "refreshToken过期,需要重新登录授权",
@@ -20,10 +20,8 @@ type UCenterLoginRequest struct { @@ -20,10 +20,8 @@ type UCenterLoginRequest struct {
20 Code string `json:"code"` 20 Code string `json:"code"`
21 GrantType string `json:"grantType" valid:"Required"` 21 GrantType string `json:"grantType" valid:"Required"`
22 //ClientId string `json:"clientId" valid:"Required"` 22 //ClientId string `json:"clientId" valid:"Required"`
23 -  
24 - Type int `json:"typoe"` //1为密码登录,管理后台登录,2为token登录,app登录  
25 -  
26 - Uid int64 `json:"uid"` // type2 23 + Type int `json:"type"` //1为密码登录,管理后台登录,2为token登录,app登录
  24 + Uid int64 `json:"uid"` // type2
27 //CompanyId int64 `json:"companyId"` // type2 25 //CompanyId int64 `json:"companyId"` // type2
28 } 26 }
29 type UCenterLoginResponse struct { 27 type UCenterLoginResponse struct {
@@ -60,7 +60,7 @@ func RequestUserCenter(method string, httpMethod, request interface{}, rsponse i @@ -60,7 +60,7 @@ func RequestUserCenter(method string, httpMethod, request interface{}, rsponse i
60 } else { 60 } else {
61 response = string(data) 61 response = string(data)
62 } 62 }
63 - log.Debug("request ucenter:%v rsp:%v", url, response) 63 + log.Debug(fmt.Sprintf("request ucenter:%v request:%v rsp:%v", url, request, response))
64 return 64 return
65 } 65 }
66 66
@@ -80,6 +80,10 @@ func ChangeUcenterUserInfo(uid int64, phone string, user *protocol.UCenterPutUse @@ -80,6 +80,10 @@ func ChangeUcenterUserInfo(uid int64, phone string, user *protocol.UCenterPutUse
80 log.Error(err) 80 log.Error(err)
81 return 81 return
82 } 82 }
  83 + if message.Errno == -1 {
  84 + err = protocol.NewErrWithMessage(1)
  85 + return
  86 + }
83 if message.Errno != 0 { 87 if message.Errno != 0 {
84 err = protocol.NewErrWithMessage(1) 88 err = protocol.NewErrWithMessage(1)
85 return 89 return
@@ -143,6 +143,10 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass @@ -143,6 +143,10 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass
143 err = protocol.NewErrWithMessage(2026) 143 err = protocol.NewErrWithMessage(2026)
144 return 144 return
145 } 145 }
  146 + if strings.EqualFold(request.NewPwd, request.OldPwd) {
  147 + err = protocol.NewErrWithMessage(2030)
  148 + return
  149 + }
146 if len(request.NewPwd) < 6 { 150 if len(request.NewPwd) < 6 {
147 err = protocol.NewErrWithMessage(2027) 151 err = protocol.NewErrWithMessage(2027)
148 return 152 return
@@ -171,7 +175,10 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass @@ -171,7 +175,10 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass
171 err = protocol.NewErrWithMessage(1) 175 err = protocol.NewErrWithMessage(1)
172 return 176 return
173 } 177 }
174 - err = agg.ChangeUcenterUserInfo(user.UserCenterId, user.Phone, &protocol.UCenterPutUserRequest{PassWord: request.NewPwd}) 178 + err = agg.ChangeUcenterUserInfo(user.UserCenterId, user.Phone, &protocol.UCenterPutUserRequest{
  179 + PassWord: request.NewPwd,
  180 + //Phone:user.Phone,
  181 + })
175 } else { 182 } else {
176 if message.Errno == -1 { 183 if message.Errno == -1 {
177 err = protocol.NewErrWithMessage(2028) 184 err = protocol.NewErrWithMessage(2028)