作者 yangfu

user auth fix

@@ -32,7 +32,7 @@ func (this *UploadController) Image() { @@ -32,7 +32,7 @@ func (this *UploadController) Image() {
32 // msg = m 32 // msg = m
33 // return 33 // return
34 //} 34 //}
35 - if request.Files, err = this.GetFiles("file"); err != nil { 35 + if request.Files, err = this.GetFiles("image"); err != nil {
36 log.Error(err) 36 log.Error(err)
37 return 37 return
38 } 38 }
@@ -4,7 +4,6 @@ import ( @@ -4,7 +4,6 @@ import (
4 "fmt" 4 "fmt"
5 "github.com/astaxie/beego/orm" 5 "github.com/astaxie/beego/orm"
6 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" 6 "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
7 - "net/http"  
8 "opp/internal/utils" 7 "opp/internal/utils"
9 "opp/models" 8 "opp/models"
10 "opp/protocol" 9 "opp/protocol"
@@ -82,11 +81,11 @@ func ChangePhone(header *protocol.RequestHeader, request *protocol.ChangePhoneRe @@ -82,11 +81,11 @@ func ChangePhone(header *protocol.RequestHeader, request *protocol.ChangePhoneRe
82 //重置密码 81 //重置密码
83 func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswordRequest) (rsp *protocol.ResetPasswordResponse, err error) { 82 func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswordRequest) (rsp *protocol.ResetPasswordResponse, err error) {
84 var ( 83 var (
85 - user *models.User  
86 - message *protocol.Message  
87 - getUserRequest *protocol.UCenterGetUserRequest = &protocol.UCenterGetUserRequest{}  
88 - getUserResponse *protocol.UCenter_GetUserResponse  
89 - result bool 84 + user *models.User
  85 + //message *protocol.Message
  86 + //getUserRequest *protocol.UCenterGetUserRequest = &protocol.UCenterGetUserRequest{}
  87 + //getUserResponse *protocol.UCenter_GetUserResponse
  88 + result bool
90 ) 89 )
91 if len(request.NewPwd) < 6 { 90 if len(request.NewPwd) < 6 {
92 err = protocol.NewErrWithMessage(2027) 91 err = protocol.NewErrWithMessage(2027)
@@ -96,7 +95,7 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo @@ -96,7 +95,7 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo
96 log.Error(err) 95 log.Error(err)
97 return 96 return
98 } 97 }
99 - if result, err = auth.CheckSmsCode(user.Phone, "", protocol.SmsCode); err != nil { 98 + if result, err = auth.CheckSmsCode(strings.TrimSpace(user.Phone), "", protocol.SmsCode); err != nil {
100 log.Error(err) 99 log.Error(err)
101 return 100 return
102 } 101 }
@@ -104,32 +103,37 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo @@ -104,32 +103,37 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo
104 err = protocol.NewErrWithMessage(1012) 103 err = protocol.NewErrWithMessage(1012)
105 return 104 return
106 } 105 }
107 - //从用户中心获取用户信息  
108 - if _, err = agg.RequestUserCenter(fmt.Sprintf("%v%v", protocol.MethodGetUser, user.UserCenterId), http.MethodGet, getUserRequest, &message); err != nil {  
109 - log.Error(err)  
110 - return  
111 - }  
112 - if message.Errno == 0 && message.Errmsg == "ok" {  
113 - if err = message.Unmarshal(&getUserResponse); err != nil {  
114 - log.Error(err)  
115 - return  
116 - }  
117 - } else {  
118 - err = protocol.NewErrWithMessage(1)  
119 - log.Error("用户中心获取数据失败: err_no:%v msg:%v", message.Errno, message.Errmsg)  
120 - return  
121 - }  
122 - if getUserResponse.Id != user.UserCenterId {  
123 - err = protocol.NewErrWithMessage(1)  
124 - log.Error(fmt.Sprintf("ucenter.id not equal input:%v want:%v", user.UserCenterId, getUserResponse.Id))  
125 - return  
126 - } 106 + ////从用户中心获取用户信息
  107 + //if _, err = agg.RequestUserCenter(fmt.Sprintf("%v%v", protocol.MethodGetUser, user.UserCenterId), http.MethodGet, getUserRequest, &message); err != nil {
  108 + // log.Error(err)
  109 + // return
  110 + //}
  111 + //if message.Errno == 0 && message.Errmsg == "ok" {
  112 + // if err = message.Unmarshal(&getUserResponse); err != nil {
  113 + // log.Error(err)
  114 + // return
  115 + // }
  116 + //} else {
  117 + // err = protocol.NewErrWithMessage(1)
  118 + // log.Error("用户中心获取数据失败: err_no:%v msg:%v", message.Errno, message.Errmsg)
  119 + // return
  120 + //}
  121 + //if getUserResponse.Id != user.UserCenterId {
  122 + // err = protocol.NewErrWithMessage(1)
  123 + // log.Error(fmt.Sprintf("ucenter.id not equal input:%v want:%v", user.UserCenterId, getUserResponse.Id))
  124 + // return
  125 + //}
127 //TODO:未验证 校验码 126 //TODO:未验证 校验码
128 if !strings.EqualFold(request.NewPwd, request.ConfirmPwd) { 127 if !strings.EqualFold(request.NewPwd, request.ConfirmPwd) {
129 err = protocol.NewErrWithMessage(2026) 128 err = protocol.NewErrWithMessage(2026)
130 return 129 return
131 } 130 }
132 err = agg.ChangeUcenterUserInfo(user.UserCenterId, user.Phone, &protocol.UCenterPutUserRequest{PassWord: request.NewPwd}) 131 err = agg.ChangeUcenterUserInfo(user.UserCenterId, user.Phone, &protocol.UCenterPutUserRequest{PassWord: request.NewPwd})
  132 + if err != nil {
  133 + err = protocol.NewErrWithMessage(1)
  134 + log.Error(err)
  135 + return
  136 + }
133 return 137 return
134 } 138 }
135 139