mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-08 11:05:59 +08:00
demo
This commit is contained in:
@@ -46,12 +46,18 @@ func Login(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.PasswordErr, "errMsg": "password err"})
|
||||
return
|
||||
}
|
||||
var userID string
|
||||
if r.UserID != "" {
|
||||
userID = r.UserID
|
||||
} else {
|
||||
userID = r.Account
|
||||
}
|
||||
url := fmt.Sprintf("http://%s:%d/auth/user_token", utils.ServerIP, config.Config.Api.GinPort[0])
|
||||
openIMGetUserToken := api.UserTokenReq{}
|
||||
openIMGetUserToken.OperationID = params.OperationID
|
||||
openIMGetUserToken.Platform = params.Platform
|
||||
openIMGetUserToken.Secret = config.Config.Secret
|
||||
openIMGetUserToken.UserID = account
|
||||
openIMGetUserToken.UserID = userID
|
||||
openIMGetUserTokenResp := api.UserTokenResp{}
|
||||
bMsg, err := http2.Post(url, openIMGetUserToken, 2)
|
||||
if err != nil {
|
||||
|
||||
@@ -15,8 +15,8 @@ type resetPasswordRequest struct {
|
||||
VerificationCode string `json:"verificationCode" binding:"required"`
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
NewPassword string `json:"newPassword" binding:"required"`
|
||||
OperationID string `json:"operationID"`
|
||||
NewPassword string `json:"newPassword" binding:"required"`
|
||||
OperationID string `json:"operationID"`
|
||||
}
|
||||
|
||||
func ResetPassword(c *gin.Context) {
|
||||
@@ -44,12 +44,14 @@ func ResetPassword(c *gin.Context) {
|
||||
}
|
||||
user, err := im_mysql_model.GetRegister(account)
|
||||
if err != nil || user.Account == "" {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "get register error", err.Error())
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "get register error", err.Error())
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NotRegistered, "errMsg": "user not register!"})
|
||||
return
|
||||
}
|
||||
if err := im_mysql_model.ResetPassword(account, req.NewPassword); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.ResetPasswordFailed, "errMsg": "reset password failed: "+err.Error()})
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.ResetPasswordFailed, "errMsg": "reset password failed: " + err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "reset password success"})
|
||||
|
||||
@@ -52,11 +52,12 @@ func SetPassword(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
userID := utils.Md5(account)
|
||||
url := config.Config.Demo.ImAPIURL + "/auth/user_register"
|
||||
openIMRegisterReq := api.UserRegisterReq{}
|
||||
openIMRegisterReq.OperationID = params.OperationID
|
||||
openIMRegisterReq.Platform = params.Platform
|
||||
openIMRegisterReq.UserID = account
|
||||
openIMRegisterReq.UserID = userID
|
||||
openIMRegisterReq.Nickname = params.Name
|
||||
openIMRegisterReq.Secret = config.Config.Secret
|
||||
openIMRegisterResp := api.UserRegisterResp{}
|
||||
@@ -76,7 +77,7 @@ func SetPassword(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.Info(params.OperationID, "begin store mysql", account, params.Password)
|
||||
err = im_mysql_model.SetPassword(account, params.Password, params.Ex)
|
||||
err = im_mysql_model.SetPassword(account, params.Password, params.Ex, userID)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "set phone number password error", account, "err", err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": err.Error()})
|
||||
@@ -84,7 +85,7 @@ func SetPassword(c *gin.Context) {
|
||||
}
|
||||
log.Info(params.OperationID, "end setPassword", account, params.Password)
|
||||
// demo onboarding
|
||||
onboardingProcess(params.OperationID, account, params.Name)
|
||||
onboardingProcess(params.OperationID, userID, params.Name)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.NoError, "errMsg": "", "data": openIMRegisterResp.UserToken})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user