add reset pwd
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
@@ -29,6 +28,7 @@ type ParamsSetPassword struct {
|
||||
func SetPassword(c *gin.Context) {
|
||||
params := ParamsSetPassword{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
@@ -39,7 +39,8 @@ func SetPassword(c *gin.Context) {
|
||||
account = params.PhoneNumber
|
||||
}
|
||||
if params.VerificationCode != config.Config.Demo.SuperCode {
|
||||
v, err := redis.String(db.DB.Exec("GET", account))
|
||||
accountKey := account + "_" + constant.VerificationCodeForRegisterSuffix
|
||||
v, err := db.DB.GetAccountCode(accountKey)
|
||||
if err != nil || v != params.VerificationCode {
|
||||
log.NewError(params.OperationID, "password Verification code error", account, params.VerificationCode)
|
||||
data := make(map[string]interface{})
|
||||
@@ -65,7 +66,7 @@ func SetPassword(c *gin.Context) {
|
||||
err = json.Unmarshal(bMsg, &openIMRegisterResp)
|
||||
if err != nil || openIMRegisterResp.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, "request openIM register error", account, "err", "")
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": ""})
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register failed: "+openIMRegisterResp.ErrMsg})
|
||||
return
|
||||
}
|
||||
log.Info(params.OperationID, "begin store mysql", account, params.Password)
|
||||
|
||||
Reference in New Issue
Block a user