|
|
@ -5,7 +5,7 @@ import (
|
|
|
|
"Open_IM/pkg/common/constant"
|
|
|
|
"Open_IM/pkg/common/constant"
|
|
|
|
"Open_IM/pkg/common/db"
|
|
|
|
"Open_IM/pkg/common/db"
|
|
|
|
"Open_IM/pkg/common/log"
|
|
|
|
"Open_IM/pkg/common/log"
|
|
|
|
|
|
|
|
"Open_IM/pkg/common/utils"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -21,12 +21,17 @@ type paramsCertification struct {
|
|
|
|
|
|
|
|
|
|
|
|
func Verify(c *gin.Context) {
|
|
|
|
func Verify(c *gin.Context) {
|
|
|
|
params := paramsCertification{}
|
|
|
|
params := paramsCertification{}
|
|
|
|
|
|
|
|
operationID := params.OperationID
|
|
|
|
|
|
|
|
|
|
|
|
if err := c.BindJSON(¶ms); err != nil {
|
|
|
|
if err := c.BindJSON(¶ms); err != nil {
|
|
|
|
log.NewError("", "request params json parsing failed", "", "err", err.Error())
|
|
|
|
log.NewError(operationID, "request params json parsing failed", "", "err", err.Error())
|
|
|
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
|
|
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.NewInfo("recv req: ", params)
|
|
|
|
if operationID == "" {
|
|
|
|
|
|
|
|
operationID = utils.OperationIDGenerator()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
log.NewInfo(operationID, "recv req: ", params)
|
|
|
|
|
|
|
|
|
|
|
|
var account string
|
|
|
|
var account string
|
|
|
|
if params.Email != "" {
|
|
|
|
if params.Email != "" {
|
|
|
@ -51,13 +56,13 @@ func Verify(c *gin.Context) {
|
|
|
|
var accountKey string
|
|
|
|
var accountKey string
|
|
|
|
switch params.UsedFor {
|
|
|
|
switch params.UsedFor {
|
|
|
|
case constant.VerificationCodeForRegister:
|
|
|
|
case constant.VerificationCodeForRegister:
|
|
|
|
accountKey = params.AreaCode + account + "_" + constant.VerificationCodeForRegisterSuffix
|
|
|
|
accountKey = account + "_" + constant.VerificationCodeForRegisterSuffix
|
|
|
|
case constant.VerificationCodeForReset:
|
|
|
|
case constant.VerificationCodeForReset:
|
|
|
|
accountKey = params.AreaCode + account + "_" + constant.VerificationCodeForResetSuffix
|
|
|
|
accountKey = account + "_" + constant.VerificationCodeForResetSuffix
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
code, err := db.DB.GetAccountCode(accountKey)
|
|
|
|
code, err := db.DB.GetAccountCode(accountKey)
|
|
|
|
log.NewInfo(params.OperationID, "redis phone number and verificating Code", accountKey, code, params)
|
|
|
|
log.NewInfo(params.OperationID, "redis phone number and verificating Code", "key: ", accountKey, "code: ", code, "params: ", params)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.NewError(params.OperationID, "Verification code expired", accountKey, "err", err.Error())
|
|
|
|
log.NewError(params.OperationID, "Verification code expired", accountKey, "err", err.Error())
|
|
|
|
data := make(map[string]interface{})
|
|
|
|
data := make(map[string]interface{})
|
|
|
|