修复多账号登录

This commit is contained in:
huangxiaolei
2022-11-28 16:15:07 +08:00
parent 7cdcb3ec09
commit 877f3dc192
15 changed files with 215 additions and 141 deletions

View File

@@ -0,0 +1,49 @@
package controller
import (
"github.com/gin-gonic/gin"
"hk4e/pkg/logger"
"net/http"
"strconv"
)
type TokenVerifyReq struct {
AccountId string `json:"accountId"`
AccountToken string `json:"accountToken"`
}
type TokenVerifyRsp struct {
Valid bool `json:"valid"`
Forbid bool `json:"forbid"`
ForbidEndTime uint32 `json:"forbidEndTime"`
PlayerID uint32 `json:"playerID"`
}
func (c *Controller) gateTokenVerify(context *gin.Context) {
tokenVerifyReq := new(TokenVerifyReq)
err := context.ShouldBindJSON(tokenVerifyReq)
if err != nil {
return
}
logger.LOG.Debug("gate token verify, req: %v", tokenVerifyReq)
accountId, err := strconv.ParseUint(tokenVerifyReq.AccountId, 10, 64)
if err != nil {
return
}
account, err := c.dao.QueryAccountByField("accountID", accountId)
if err != nil || account == nil {
context.JSON(http.StatusOK, &TokenVerifyRsp{
Valid: false,
Forbid: false,
ForbidEndTime: 0,
PlayerID: 0,
})
return
}
context.JSON(http.StatusOK, &TokenVerifyRsp{
Valid: true,
Forbid: account.Forbid,
ForbidEndTime: uint32(account.ForbidEndTime),
PlayerID: uint32(account.PlayerID),
})
}