作者 yangfu

user auth fix

... ... @@ -32,7 +32,7 @@ func (this *UploadController) Image() {
// msg = m
// return
//}
if request.Files, err = this.GetFiles("file"); err != nil {
if request.Files, err = this.GetFiles("image"); err != nil {
log.Error(err)
return
}
... ...
... ... @@ -4,7 +4,6 @@ import (
"fmt"
"github.com/astaxie/beego/orm"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"net/http"
"opp/internal/utils"
"opp/models"
"opp/protocol"
... ... @@ -82,11 +81,11 @@ func ChangePhone(header *protocol.RequestHeader, request *protocol.ChangePhoneRe
//重置密码
func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswordRequest) (rsp *protocol.ResetPasswordResponse, err error) {
var (
user *models.User
message *protocol.Message
getUserRequest *protocol.UCenterGetUserRequest = &protocol.UCenterGetUserRequest{}
getUserResponse *protocol.UCenter_GetUserResponse
result bool
user *models.User
//message *protocol.Message
//getUserRequest *protocol.UCenterGetUserRequest = &protocol.UCenterGetUserRequest{}
//getUserResponse *protocol.UCenter_GetUserResponse
result bool
)
if len(request.NewPwd) < 6 {
err = protocol.NewErrWithMessage(2027)
... ... @@ -96,7 +95,7 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo
log.Error(err)
return
}
if result, err = auth.CheckSmsCode(user.Phone, "", protocol.SmsCode); err != nil {
if result, err = auth.CheckSmsCode(strings.TrimSpace(user.Phone), "", protocol.SmsCode); err != nil {
log.Error(err)
return
}
... ... @@ -104,32 +103,37 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo
err = protocol.NewErrWithMessage(1012)
return
}
//从用户中心获取用户信息
if _, err = agg.RequestUserCenter(fmt.Sprintf("%v%v", protocol.MethodGetUser, user.UserCenterId), http.MethodGet, getUserRequest, &message); err != nil {
log.Error(err)
return
}
if message.Errno == 0 && message.Errmsg == "ok" {
if err = message.Unmarshal(&getUserResponse); err != nil {
log.Error(err)
return
}
} else {
err = protocol.NewErrWithMessage(1)
log.Error("用户中心获取数据失败: err_no:%v msg:%v", message.Errno, message.Errmsg)
return
}
if getUserResponse.Id != user.UserCenterId {
err = protocol.NewErrWithMessage(1)
log.Error(fmt.Sprintf("ucenter.id not equal input:%v want:%v", user.UserCenterId, getUserResponse.Id))
return
}
////从用户中心获取用户信息
//if _, err = agg.RequestUserCenter(fmt.Sprintf("%v%v", protocol.MethodGetUser, user.UserCenterId), http.MethodGet, getUserRequest, &message); err != nil {
// log.Error(err)
// return
//}
//if message.Errno == 0 && message.Errmsg == "ok" {
// if err = message.Unmarshal(&getUserResponse); err != nil {
// log.Error(err)
// return
// }
//} else {
// err = protocol.NewErrWithMessage(1)
// log.Error("用户中心获取数据失败: err_no:%v msg:%v", message.Errno, message.Errmsg)
// return
//}
//if getUserResponse.Id != user.UserCenterId {
// err = protocol.NewErrWithMessage(1)
// log.Error(fmt.Sprintf("ucenter.id not equal input:%v want:%v", user.UserCenterId, getUserResponse.Id))
// return
//}
//TODO:未验证 校验码
if !strings.EqualFold(request.NewPwd, request.ConfirmPwd) {
err = protocol.NewErrWithMessage(2026)
return
}
err = agg.ChangeUcenterUserInfo(user.UserCenterId, user.Phone, &protocol.UCenterPutUserRequest{PassWord: request.NewPwd})
if err != nil {
err = protocol.NewErrWithMessage(1)
log.Error(err)
return
}
return
}
... ...