mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-19 08:19:01 +08:00
Merge branch 'superGroup' of github.com:OpenIMSDK/Open-IM-Server into superGroup
This commit is contained in:
@@ -6,11 +6,13 @@ import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/utils"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gopkg.in/gomail.v2"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -41,11 +43,17 @@ type paramsVerificationCode struct {
|
||||
|
||||
func SendVerificationCode(c *gin.Context) {
|
||||
params := paramsVerificationCode{}
|
||||
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("", "BindJSON failed", "err:", err.Error(), "phoneNumber", params.PhoneNumber, "email", params.Email)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
operationID := params.OperationID
|
||||
if operationID == "" {
|
||||
operationID = utils.OperationIDGenerator()
|
||||
}
|
||||
log.Info(operationID, "SendVerificationCode args: ", "area code: ", params.AreaCode, "Phone Number: ", params.PhoneNumber)
|
||||
var account string
|
||||
if params.Email != "" {
|
||||
account = params.Email
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
|
||||
"Open_IM/pkg/common/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
@@ -21,12 +21,17 @@ type paramsCertification struct {
|
||||
|
||||
func Verify(c *gin.Context) {
|
||||
params := paramsCertification{}
|
||||
operationID := params.OperationID
|
||||
|
||||
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()})
|
||||
return
|
||||
}
|
||||
log.NewInfo("recv req: ", params)
|
||||
if operationID == "" {
|
||||
operationID = utils.OperationIDGenerator()
|
||||
}
|
||||
log.NewInfo(operationID, "recv req: ", params)
|
||||
|
||||
var account string
|
||||
if params.Email != "" {
|
||||
@@ -51,13 +56,13 @@ func Verify(c *gin.Context) {
|
||||
var accountKey string
|
||||
switch params.UsedFor {
|
||||
case constant.VerificationCodeForRegister:
|
||||
accountKey = params.AreaCode + account + "_" + constant.VerificationCodeForRegisterSuffix
|
||||
accountKey = account + "_" + constant.VerificationCodeForRegisterSuffix
|
||||
case constant.VerificationCodeForReset:
|
||||
accountKey = params.AreaCode + account + "_" + constant.VerificationCodeForResetSuffix
|
||||
accountKey = account + "_" + constant.VerificationCodeForResetSuffix
|
||||
}
|
||||
|
||||
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 {
|
||||
log.NewError(params.OperationID, "Verification code expired", accountKey, "err", err.Error())
|
||||
data := make(map[string]interface{})
|
||||
|
||||
Reference in New Issue
Block a user