mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Merge remote-tracking branch 'origin/superGroup' into superGroup
This commit is contained in:
commit
9a813030a3
@ -15,6 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ParamsLogin struct {
|
type ParamsLogin struct {
|
||||||
|
UserID string `json:"userID"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
PhoneNumber string `json:"phoneNumber"`
|
PhoneNumber string `json:"phoneNumber"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
@ -32,11 +33,13 @@ func Login(c *gin.Context) {
|
|||||||
var account string
|
var account string
|
||||||
if params.Email != "" {
|
if params.Email != "" {
|
||||||
account = params.Email
|
account = params.Email
|
||||||
} else {
|
} else if params.PhoneNumber != "" {
|
||||||
account = 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 {
|
if err != nil {
|
||||||
log.NewError(params.OperationID, "user have not register", params.Password, account, err.Error())
|
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"})
|
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
|
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 || user.Account == "" {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "get register error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "get register error", err.Error())
|
||||||
|
@ -66,7 +66,7 @@ func SendVerificationCode(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
switch params.UsedFor {
|
switch params.UsedFor {
|
||||||
case constant.VerificationCodeForRegister:
|
case constant.VerificationCodeForRegister:
|
||||||
_, err := im_mysql_model.GetRegister(account, params.AreaCode)
|
_, err := im_mysql_model.GetRegister(account, params.AreaCode, "")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.NewError(params.OperationID, "The phone number has been registered", params)
|
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"})
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.HasRegistered, "errMsg": "The phone number has been registered"})
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ParamsSetPassword struct {
|
type ParamsSetPassword struct {
|
||||||
|
UserID string `json:"userID"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Nickname string `json:"nickname"`
|
Nickname string `json:"nickname"`
|
||||||
PhoneNumber string `json:"phoneNumber"`
|
PhoneNumber string `json:"phoneNumber"`
|
||||||
@ -40,12 +41,15 @@ func SetPassword(c *gin.Context) {
|
|||||||
var account string
|
var account string
|
||||||
if params.Email != "" {
|
if params.Email != "" {
|
||||||
account = params.Email
|
account = params.Email
|
||||||
} else {
|
} else if params.PhoneNumber != "" {
|
||||||
account = params.PhoneNumber
|
account = params.PhoneNumber
|
||||||
|
} else {
|
||||||
|
account = params.UserID
|
||||||
}
|
}
|
||||||
if params.Nickname == "" {
|
if params.Nickname == "" {
|
||||||
params.Nickname = account
|
params.Nickname = account
|
||||||
}
|
}
|
||||||
|
if params.UserID == "" {
|
||||||
if (config.Config.Demo.UseSuperCode && params.VerificationCode != config.Config.Demo.SuperCode) || !config.Config.Demo.UseSuperCode {
|
if (config.Config.Demo.UseSuperCode && params.VerificationCode != config.Config.Demo.SuperCode) || !config.Config.Demo.UseSuperCode {
|
||||||
accountKey := params.AreaCode + account + "_" + constant.VerificationCodeForRegisterSuffix
|
accountKey := params.AreaCode + account + "_" + constant.VerificationCodeForRegisterSuffix
|
||||||
v, err := db.DB.GetAccountCode(accountKey)
|
v, err := db.DB.GetAccountCode(accountKey)
|
||||||
@ -57,12 +61,17 @@ func SetPassword(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//userID := utils.Base64Encode(account)
|
//userID := utils.Base64Encode(account)
|
||||||
|
var userID string
|
||||||
|
if params.UserID == "" {
|
||||||
userID := utils.Md5(params.OperationID + strconv.FormatInt(time.Now().UnixNano(), 10))
|
userID := utils.Md5(params.OperationID + strconv.FormatInt(time.Now().UnixNano(), 10))
|
||||||
bi := big.NewInt(0)
|
bi := big.NewInt(0)
|
||||||
bi.SetString(userID[0:8], 16)
|
bi.SetString(userID[0:8], 16)
|
||||||
userID = bi.String()
|
userID = bi.String()
|
||||||
|
} else {
|
||||||
|
userID = params.UserID
|
||||||
|
}
|
||||||
|
|
||||||
url := config.Config.Demo.ImAPIURL + "/auth/user_register"
|
url := config.Config.Demo.ImAPIURL + "/auth/user_register"
|
||||||
openIMRegisterReq := api.UserRegisterReq{}
|
openIMRegisterReq := api.UserRegisterReq{}
|
||||||
@ -97,7 +106,9 @@ func SetPassword(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
log.Info(params.OperationID, "end setPassword", account, params.Password)
|
log.Info(params.OperationID, "end setPassword", account, params.Password)
|
||||||
// demo onboarding
|
// demo onboarding
|
||||||
|
if params.UserID == "" {
|
||||||
onboardingProcess(params.OperationID, userID, params.Nickname, params.FaceURL, params.AreaCode+params.PhoneNumber, params.Email)
|
onboardingProcess(params.OperationID, userID, params.Nickname, params.FaceURL, params.AreaCode+params.PhoneNumber, params.Email)
|
||||||
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMRegisterResp.UserToken})
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMRegisterResp.UserToken})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,14 @@ import (
|
|||||||
_ "github.com/jinzhu/gorm"
|
_ "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()
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var r db.Register
|
var r db.Register
|
||||||
return &r, dbConn.Table("registers").Where("account = ? or account =? and area_code=?",
|
return &r, dbConn.Table("registers").Where("user_id = ? and user_id != ? or account = ? or account =? and area_code=?",
|
||||||
account, account, areaCode).Take(&r).Error
|
userID, "", account, account, areaCode).Take(&r).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetPassword(account, password, ex, userID, areaCode string) error {
|
func SetPassword(account, password, ex, userID, areaCode string) error {
|
||||||
|
@ -302,6 +302,6 @@ func GetRandomDepartmentID() (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
department := &db.Department{}
|
department := &db.Department{}
|
||||||
err = dbConn.Model(department).Order("RAND()").Where("related_group_id != ? AND department_id != ?", "", "0").First(department).Error
|
err = dbConn.Model(department).Order("RAND()").Where("related_group_id != ? AND department_id != ? AND department_type = ?", "", "0", 1).First(department).Error
|
||||||
return department.DepartmentID, err
|
return department.DepartmentID, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user