pull/249/head
wangchuxiao 3 years ago
parent b0669b7eea
commit d0e7147911

@ -15,6 +15,7 @@ import (
)
type ParamsLogin struct {
UserID string `json:"userID"`
Email string `json:"email"`
PhoneNumber string `json:"phoneNumber"`
Password string `json:"password"`
@ -32,11 +33,13 @@ func Login(c *gin.Context) {
var account string
if params.Email != "" {
account = params.Email
} else {
} else if params.PhoneNumber != "" {
account = params.PhoneNumber
} else {
account = params.UserID
}
r, err := im_mysql_model.GetRegister(account, params.AreaCode)
r, err := im_mysql_model.GetRegister(account, params.AreaCode, params.UserID)
if err != nil {
log.NewError(params.OperationID, "user have not register", params.Password, account, err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.NotRegistered, "errMsg": "Mobile phone number is not registered"})

@ -44,7 +44,7 @@ func ResetPassword(c *gin.Context) {
return
}
}
user, err := im_mysql_model.GetRegister(account, req.AreaCode)
user, err := im_mysql_model.GetRegister(account, req.AreaCode, "")
if err != nil || user.Account == "" {
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "get register error", err.Error())

@ -66,7 +66,7 @@ func SendVerificationCode(c *gin.Context) {
}
switch params.UsedFor {
case constant.VerificationCodeForRegister:
_, err := im_mysql_model.GetRegister(account, params.AreaCode)
_, err := im_mysql_model.GetRegister(account, params.AreaCode, "")
if err == nil {
log.NewError(params.OperationID, "The phone number has been registered", params)
c.JSON(http.StatusOK, gin.H{"errCode": constant.HasRegistered, "errMsg": "The phone number has been registered"})

@ -5,14 +5,14 @@ import (
_ "github.com/jinzhu/gorm"
)
func GetRegister(account, areaCode string) (*db.Register, error) {
func GetRegister(account, areaCode, userID string) (*db.Register, error) {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return nil, err
}
var r db.Register
return &r, dbConn.Table("registers").Where("account = ? or account =? and area_code=?",
account, account, areaCode).Take(&r).Error
return &r, dbConn.Table("registers").Where("user_id = ? and user_id != ? or account = ? or account =? and area_code=?",
userID, "", account, account, areaCode).Take(&r).Error
}
func SetPassword(account, password, ex, userID, areaCode string) error {

Loading…
Cancel
Save