|
|
|
@ -18,6 +18,7 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ParamsSetPassword struct {
|
|
|
|
|
UserID string `json:"userID"`
|
|
|
|
|
Email string `json:"email"`
|
|
|
|
|
Nickname string `json:"nickname"`
|
|
|
|
|
PhoneNumber string `json:"phoneNumber"`
|
|
|
|
@ -40,12 +41,15 @@ func SetPassword(c *gin.Context) {
|
|
|
|
|
var account string
|
|
|
|
|
if params.Email != "" {
|
|
|
|
|
account = params.Email
|
|
|
|
|
} else {
|
|
|
|
|
} else if params.PhoneNumber != "" {
|
|
|
|
|
account = params.PhoneNumber
|
|
|
|
|
} else {
|
|
|
|
|
account = params.UserID
|
|
|
|
|
}
|
|
|
|
|
if params.Nickname == "" {
|
|
|
|
|
params.Nickname = account
|
|
|
|
|
}
|
|
|
|
|
if params.UserID == "" {
|
|
|
|
|
if (config.Config.Demo.UseSuperCode && params.VerificationCode != config.Config.Demo.SuperCode) || !config.Config.Demo.UseSuperCode {
|
|
|
|
|
accountKey := params.AreaCode + account + "_" + constant.VerificationCodeForRegisterSuffix
|
|
|
|
|
v, err := db.DB.GetAccountCode(accountKey)
|
|
|
|
@ -57,12 +61,17 @@ func SetPassword(c *gin.Context) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//userID := utils.Base64Encode(account)
|
|
|
|
|
|
|
|
|
|
var userID string
|
|
|
|
|
if params.UserID == "" {
|
|
|
|
|
userID := utils.Md5(params.OperationID + strconv.FormatInt(time.Now().UnixNano(), 10))
|
|
|
|
|
bi := big.NewInt(0)
|
|
|
|
|
bi.SetString(userID[0:8], 16)
|
|
|
|
|
userID = bi.String()
|
|
|
|
|
} else {
|
|
|
|
|
userID = params.UserID
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
url := config.Config.Demo.ImAPIURL + "/auth/user_register"
|
|
|
|
|
openIMRegisterReq := api.UserRegisterReq{}
|
|
|
|
@ -97,7 +106,9 @@ func SetPassword(c *gin.Context) {
|
|
|
|
|
}
|
|
|
|
|
log.Info(params.OperationID, "end setPassword", account, params.Password)
|
|
|
|
|
// demo onboarding
|
|
|
|
|
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})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|