pull/249/head
wangchuxiao 2 years ago
parent d0e7147911
commit 3ad3b30d97

@ -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,29 +41,37 @@ 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 (config.Config.Demo.UseSuperCode && params.VerificationCode != config.Config.Demo.SuperCode) || !config.Config.Demo.UseSuperCode { if params.UserID == "" {
accountKey := params.AreaCode + account + "_" + constant.VerificationCodeForRegisterSuffix if (config.Config.Demo.UseSuperCode && params.VerificationCode != config.Config.Demo.SuperCode) || !config.Config.Demo.UseSuperCode {
v, err := db.DB.GetAccountCode(accountKey) accountKey := params.AreaCode + account + "_" + constant.VerificationCodeForRegisterSuffix
if err != nil || v != params.VerificationCode { v, err := db.DB.GetAccountCode(accountKey)
log.NewError(params.OperationID, "password Verification code error", account, params.VerificationCode) if err != nil || v != params.VerificationCode {
data := make(map[string]interface{}) log.NewError(params.OperationID, "password Verification code error", account, params.VerificationCode)
data["PhoneNumber"] = account data := make(map[string]interface{})
c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code error!", "data": data}) data["PhoneNumber"] = account
return c.JSON(http.StatusOK, gin.H{"errCode": constant.CodeInvalidOrExpired, "errMsg": "Verification code error!", "data": data})
return
}
} }
} }
//userID := utils.Base64Encode(account) //userID := utils.Base64Encode(account)
var userID string
userID := utils.Md5(params.OperationID + strconv.FormatInt(time.Now().UnixNano(), 10)) if params.UserID == "" {
bi := big.NewInt(0) userID := utils.Md5(params.OperationID + strconv.FormatInt(time.Now().UnixNano(), 10))
bi.SetString(userID[0:8], 16) bi := big.NewInt(0)
userID = bi.String() bi.SetString(userID[0:8], 16)
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
onboardingProcess(params.OperationID, userID, params.Nickname, params.FaceURL, params.AreaCode+params.PhoneNumber, params.Email) if params.UserID == "" {
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
} }

@ -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…
Cancel
Save