解决冲突
This commit is contained in:
commit
ff04ab8e0f
|
@ -4,7 +4,9 @@ import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/golang-jwt/jwt/v4"
|
||||||
"io"
|
"io"
|
||||||
|
"mongo.games.com/game/webapi"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -72,7 +74,21 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
s.Send(int(login_proto.GatePacketID_PACKET_SS_DICONNECT), ssDis)
|
s.Send(int(login_proto.GatePacketID_PACKET_SS_DICONNECT), ssDis)
|
||||||
}
|
}
|
||||||
|
|
||||||
if csl.GetUsername() == "" || csl.GetPassword() == "" {
|
if csl.GetLoginType() == common.LoginTypePlatformToken {
|
||||||
|
claims, err := webapi.ParseJwtWithClaims([]byte(common.Config.AppId), csl.Token)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Logger.Tracef("(this *CSLoginHandler) Process ParseJwtWithClaims: claims:%v", claims.(jwt.MapClaims))
|
||||||
|
|
||||||
|
username := (claims.(jwt.MapClaims))["Username"].(string)
|
||||||
|
{
|
||||||
|
csl.Username = username
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (csl.GetUsername() == "" || csl.GetPassword() == "") && csl.GetLoginType() != common.LoginTypePlatformToken {
|
||||||
sendSCLogin(login_proto.OpResultCode_OPRC_Error)
|
sendSCLogin(login_proto.OpResultCode_OPRC_Error)
|
||||||
sendSCDisconnect(common.KickReason_Freeze)
|
sendSCDisconnect(common.KickReason_Freeze)
|
||||||
return nil
|
return nil
|
||||||
|
@ -123,7 +139,7 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
h := md5.New()
|
h := md5.New()
|
||||||
io.WriteString(h, raw)
|
io.WriteString(h, raw)
|
||||||
hashsum := hex.EncodeToString(h.Sum(nil))
|
hashsum := hex.EncodeToString(h.Sum(nil))
|
||||||
if hashsum != csl.GetSign() {
|
if hashsum != csl.GetSign() && csl.GetLoginType() != common.LoginTypePlatformToken {
|
||||||
logger.Logger.Tracef("ClientSessionAttribute_State hashsum not fit!!! get:%v expect:%v rawstr:%v", csl.GetSign(), hashsum, raw)
|
logger.Logger.Tracef("ClientSessionAttribute_State hashsum not fit!!! get:%v expect:%v rawstr:%v", csl.GetSign(), hashsum, raw)
|
||||||
sendSCLogin(login_proto.OpResultCode_OPRC_Error)
|
sendSCLogin(login_proto.OpResultCode_OPRC_Error)
|
||||||
sendSCDisconnect(common.KickReason_CheckCodeErr)
|
sendSCDisconnect(common.KickReason_CheckCodeErr)
|
||||||
|
@ -250,7 +266,6 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
|
|
||||||
// 用缓存信息做登录,有account
|
// 用缓存信息做登录,有account
|
||||||
// 根据StartLogin代码,这里ls.acc一定不为nil
|
// 根据StartLogin代码,这里ls.acc一定不为nil
|
||||||
// 验证token
|
|
||||||
ls = LoginStateMgrSington.GetLoginStateByName(UserKey(csl.GetUsername(), csl.GetPlatform(), tagkey))
|
ls = LoginStateMgrSington.GetLoginStateByName(UserKey(csl.GetUsername(), csl.GetPlatform(), tagkey))
|
||||||
if ls != nil {
|
if ls != nil {
|
||||||
acc := ls.acc
|
acc := ls.acc
|
||||||
|
@ -325,6 +340,18 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case common.LoginTypePlatformToken:
|
||||||
|
// 验证token
|
||||||
|
pwdIsErr = true
|
||||||
|
|
||||||
|
//expire := (claims.(jwt.MapClaims))["Exp"].(int64)
|
||||||
|
////timeStamp := (claims.(jwt.MapClaims))["Timestamp"]
|
||||||
|
//
|
||||||
|
//if username == username && expire <= time.Now().Add(time.Hour*24).Unix() {
|
||||||
|
// pwdIsErr = true
|
||||||
|
//} else {
|
||||||
|
// pwdIsErr = false
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
//密码错误
|
//密码错误
|
||||||
|
|
|
@ -4,7 +4,9 @@ import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/golang-jwt/jwt/v4"
|
||||||
"io"
|
"io"
|
||||||
|
"mongo.games.com/game/webapi"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -39,20 +41,24 @@ type TaskLogin struct {
|
||||||
func (t *TaskLogin) Call(o *basic.Object) interface{} {
|
func (t *TaskLogin) Call(o *basic.Object) interface{} {
|
||||||
var playerData *model.PlayerData
|
var playerData *model.PlayerData
|
||||||
|
|
||||||
// token验证
|
if t.GetLoginType() == common.LoginTypePlatformToken {
|
||||||
//claims, err := webapi.ParseJwtWithClaims([]byte(common.Config.AppId), t.Token)
|
//token验证
|
||||||
//if err != nil {
|
claims, err := webapi.ParseJwtWithClaims([]byte(common.Config.AppId), t.Token)
|
||||||
// return nil
|
if err != nil {
|
||||||
//}
|
return nil
|
||||||
//
|
}
|
||||||
//logger.Logger.Tracef("TaskLogin ParseJwtWithClaims: claims:%v", claims.(jwt.MapClaims))
|
|
||||||
|
logger.Logger.Tracef("TaskLogin ParseJwtWithClaims: claims:%v", claims.(jwt.MapClaims))
|
||||||
|
|
||||||
|
username := (claims.(jwt.MapClaims))["Username"].(string)
|
||||||
|
t.Username = username
|
||||||
|
}
|
||||||
|
|
||||||
//username := (claims.(jwt.MapClaims))["Username"]
|
|
||||||
//expire := (claims.(jwt.MapClaims))["Exp"]
|
//expire := (claims.(jwt.MapClaims))["Exp"]
|
||||||
//timeStamp := (claims.(jwt.MapClaims))["Timestamp"]
|
//timeStamp := (claims.(jwt.MapClaims))["Timestamp"]
|
||||||
|
|
||||||
acc, retCode := model.AccountIsExist(t.GetUsername(), t.GetUsername(), t.GetPassword(), t.GetPlatform(),
|
acc, retCode := model.AccountIsExist(t.GetUsername(), t.GetUsername(), t.GetPassword(), t.GetPlatform(),
|
||||||
t.GetTimeStamp(), t.GetLoginType(), t.tagkey, false, t.codeValid)
|
t.GetTimeStamp(), common.LoginTypePlatformToken, t.tagkey, false, t.codeValid)
|
||||||
|
|
||||||
switch retCode {
|
switch retCode {
|
||||||
case common.LoginOk:
|
case common.LoginOk:
|
||||||
|
|
Loading…
Reference in New Issue