Merge branch 'superGroup' of github.com:OpenIMSDK/Open-IM-Server into superGroup

pull/241/head
wangchuxiao 2 years ago
commit 36667b8649

@ -70,11 +70,11 @@ kafka:
#如果是单机模式用0.0.0.0或者不填,默认即可 #如果是单机模式用0.0.0.0或者不填,默认即可
serverip: 0.0.0.0 serverip: 0.0.0.0
#作为rpc时注册到etcd的地址单机默认即可如果是集群部署需要修改具体使用内网地址还是外网地址要依情况而定目的是api/gateway能访问到
rpcRegisterIP: 127.0.0.1 rpcRegisterIP: 127.0.0.1
#默认即可
listenIP: 0.0.0.0 listenIP: 0.0.0.0
# endpoints 内部组件间访问的端点host名称访问时可以内部直接访问 host:port 来访问 # endpoints 内部组件间访问的端点host名称访问时可以内部直接访问 host:port 来访问
endpoints: endpoints:
api: openim_api api: openim_api

@ -78,7 +78,6 @@ services:
KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://:9093 KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://:9093
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT" KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT"
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
network_mode: "host"
depends_on: depends_on:
- zookeeper - zookeeper

@ -6,11 +6,13 @@ import (
"Open_IM/pkg/common/db" "Open_IM/pkg/common/db"
"Open_IM/pkg/common/db/mysql_model/im_mysql_model" "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
"Open_IM/pkg/common/utils"
"fmt" "fmt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gopkg.in/gomail.v2" "gopkg.in/gomail.v2"
"math/rand" "math/rand"
"net/http" "net/http"
"time" "time"
) )
@ -41,11 +43,17 @@ type paramsVerificationCode struct {
func SendVerificationCode(c *gin.Context) { func SendVerificationCode(c *gin.Context) {
params := paramsVerificationCode{} params := paramsVerificationCode{}
if err := c.BindJSON(&params); err != nil { if err := c.BindJSON(&params); err != nil {
log.NewError("", "BindJSON failed", "err:", err.Error(), "phoneNumber", params.PhoneNumber, "email", params.Email) 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()}) c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
return 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 var account string
if params.Email != "" { if params.Email != "" {
account = params.Email account = params.Email

@ -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(&params); err != nil { if err := c.BindJSON(&params); 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{})

Loading…
Cancel
Save