parent
7aaf7e510a
commit
d6600c0e08
|
@ -328,8 +328,6 @@ const (
|
||||||
GainWayGuide2 = 117 // 竞技馆引导奖励
|
GainWayGuide2 = 117 // 竞技馆引导奖励
|
||||||
GainWayCompound = 118 // 道具合成消耗
|
GainWayCompound = 118 // 道具合成消耗
|
||||||
GainWayCompoundGain = 119 // 道具合成获得
|
GainWayCompoundGain = 119 // 道具合成获得
|
||||||
GainWayPlatformIn = 120 // 平台上分
|
|
||||||
GainWayPlatformOut = 121 // 平台下分
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 后台选择 金币变化类型 的充值 类型id号起始
|
// 后台选择 金币变化类型 的充值 类型id号起始
|
||||||
|
|
|
@ -64,7 +64,7 @@ message CSLogin {
|
||||||
int32 InviterId = 8; //邀请人ID
|
int32 InviterId = 8; //邀请人ID
|
||||||
int32 ApkVer = 9; //apk版本号
|
int32 ApkVer = 9; //apk版本号
|
||||||
int32 ResVer = 10; //资源版本号
|
int32 ResVer = 10; //资源版本号
|
||||||
int32 LoginType = 11; //登录类型 0:游客登录 1:帐号登录 2:手机号登录 6:谷歌,facebook 7: 平台token登录
|
int32 LoginType = 11; //登录类型 0:游客登录 1:帐号登录 2:手机号登录 6:谷歌,facebook
|
||||||
string PlatformTag = 12;//android包名或者ios标记
|
string PlatformTag = 12;//android包名或者ios标记
|
||||||
string DeviceOs = 13; //系统android,ios,windows
|
string DeviceOs = 13; //系统android,ios,windows
|
||||||
string Promoter = 14; //推广员
|
string Promoter = 14; //推广员
|
||||||
|
|
|
@ -4,9 +4,7 @@ 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"
|
||||||
|
|
||||||
|
@ -74,19 +72,7 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
claims, err := webapi.ParseJwtWithClaims([]byte(common.Config.AppId), csl.Token)
|
if csl.GetUsername() == "" || csl.GetPassword() == "" {
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.Logger.Tracef("(this *CSLoginHandler) Process ParseJwtWithClaims: claims:%v", claims.(jwt.MapClaims))
|
|
||||||
|
|
||||||
username := (claims.(jwt.MapClaims))["Username"].(string)
|
|
||||||
if csl.GetLoginType() == common.LoginTypePlatformToken {
|
|
||||||
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
|
||||||
|
@ -137,7 +123,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() && csl.GetLoginType() != common.LoginTypePlatformToken {
|
if hashsum != csl.GetSign() {
|
||||||
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)
|
||||||
|
@ -214,17 +200,17 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
}
|
}
|
||||||
|
|
||||||
// 玩家是否有在登录的连接
|
// 玩家是否有在登录的连接
|
||||||
if LoginStateMgrSington.IsLogining(username, csl.GetPlatform(), tagkey) {
|
if LoginStateMgrSington.IsLogining(csl.GetUsername(), csl.GetPlatform(), tagkey) {
|
||||||
logger.Logger.Warnf("CSLoginHandler logining (%v) disconnect current(%v) ", csl.GetUsername(), sid)
|
logger.Logger.Warnf("CSLoginHandler logining (%v) disconnect current(%v) ", csl.GetUsername(), sid)
|
||||||
sendSCDisconnect(common.KickReason_Logining) // 登录中重复登录会被断开连接
|
sendSCDisconnect(common.KickReason_Logining) // 登录中重复登录会被断开连接
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 玩家已经登录完成并且在游戏中,断开当前连接
|
// 玩家已经登录完成并且在游戏中,断开当前连接
|
||||||
ls := LoginStateMgrSington.GetLoginStateByName(UserKey(username, csl.GetPlatform(), tagkey))
|
ls := LoginStateMgrSington.GetLoginStateByName(UserKey(csl.GetUsername(), csl.GetPlatform(), tagkey))
|
||||||
if ls != nil && ls.acc != nil {
|
if ls != nil && ls.acc != nil {
|
||||||
// lss 其它连接
|
// lss 其它连接
|
||||||
lss := LoginStateMgrSington.LoginFinish(username, csl.GetPlatform(), sid, ls.acc, tagkey)
|
lss := LoginStateMgrSington.LoginFinish(csl.GetUsername(), csl.GetPlatform(), sid, ls.acc, tagkey)
|
||||||
player := PlayerMgrSington.GetPlayerBySnId(ls.acc.SnId)
|
player := PlayerMgrSington.GetPlayerBySnId(ls.acc.SnId)
|
||||||
waitMatch := false
|
waitMatch := false
|
||||||
if player != nil {
|
if player != nil {
|
||||||
|
@ -243,7 +229,7 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
ResVer: csl.GetResVer(),
|
ResVer: csl.GetResVer(),
|
||||||
InviterId: csl.GetInviterId(),
|
InviterId: csl.GetInviterId(),
|
||||||
PromoterTree: csl.GetPromoterTree(),
|
PromoterTree: csl.GetPromoterTree(),
|
||||||
UserName: username,
|
UserName: csl.GetUsername(),
|
||||||
PlatformTag: csl.GetPlatformTag(),
|
PlatformTag: csl.GetPlatformTag(),
|
||||||
Promoter: csl.GetPromoter(),
|
Promoter: csl.GetPromoter(),
|
||||||
Sid: sid,
|
Sid: sid,
|
||||||
|
@ -252,7 +238,7 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
}
|
}
|
||||||
|
|
||||||
// 玩家开始登录
|
// 玩家开始登录
|
||||||
if LoginStateMgrSington.StartLogin(username, csl.GetPlatform(), sid, s, clog, tagkey) {
|
if LoginStateMgrSington.StartLogin(csl.GetUsername(), csl.GetPlatform(), sid, s, clog, tagkey) {
|
||||||
tl := &TaskLogin{CSLogin: csl, Session: s, Sid: sid, BackupPromoter: backupPromoter, tagkey: tagkey, codeValid: codeValid}
|
tl := &TaskLogin{CSLogin: csl, Session: s, Sid: sid, BackupPromoter: backupPromoter, tagkey: tagkey, codeValid: codeValid}
|
||||||
t := task.New(nil, tl, tl, "TaskLogin")
|
t := task.New(nil, tl, tl, "TaskLogin")
|
||||||
if b := t.StartByExecutor(csl.GetUsername()); !b {
|
if b := t.StartByExecutor(csl.GetUsername()); !b {
|
||||||
|
@ -264,7 +250,8 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
|
|
||||||
// 用缓存信息做登录,有account
|
// 用缓存信息做登录,有account
|
||||||
// 根据StartLogin代码,这里ls.acc一定不为nil
|
// 根据StartLogin代码,这里ls.acc一定不为nil
|
||||||
ls = LoginStateMgrSington.GetLoginStateByName(UserKey(username, csl.GetPlatform(), tagkey))
|
// 验证token
|
||||||
|
ls = LoginStateMgrSington.GetLoginStateByName(UserKey(csl.GetUsername(), csl.GetPlatform(), tagkey))
|
||||||
if ls != nil {
|
if ls != nil {
|
||||||
acc := ls.acc
|
acc := ls.acc
|
||||||
// 账号冻结
|
// 账号冻结
|
||||||
|
@ -279,7 +266,7 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
pwdIsErr := true
|
pwdIsErr := true
|
||||||
switch csl.GetLoginType() {
|
switch csl.GetLoginType() {
|
||||||
case common.LoginTypeGuest: //游客登录
|
case common.LoginTypeGuest: //游客登录
|
||||||
if acc.UserName == username && acc.Platform == csl.GetPlatform() && acc.TagKey == tagkey {
|
if acc.UserName == csl.GetUsername() && acc.Platform == csl.GetPlatform() && acc.TagKey == tagkey {
|
||||||
raw := fmt.Sprintf("%v%v%v", acc.PassWord, common.GetAppId(), csl.GetTimeStamp())
|
raw := fmt.Sprintf("%v%v%v", acc.PassWord, common.GetAppId(), csl.GetTimeStamp())
|
||||||
h := md5.New()
|
h := md5.New()
|
||||||
io.WriteString(h, raw)
|
io.WriteString(h, raw)
|
||||||
|
@ -291,7 +278,7 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case common.LoginTypeAccount: //帐号登录
|
case common.LoginTypeAccount: //帐号登录
|
||||||
if acc.UserName == username && acc.Platform == csl.GetPlatform() && acc.TagKey == tagkey {
|
if acc.UserName == csl.GetUsername() && acc.Platform == csl.GetPlatform() && acc.TagKey == tagkey {
|
||||||
// 用户密码
|
// 用户密码
|
||||||
userPwd := common.GetRawPassword(acc.TelPassWord, csl.GetTimeStamp())
|
userPwd := common.GetRawPassword(acc.TelPassWord, csl.GetTimeStamp())
|
||||||
if userPwd != csl.GetPassword() {
|
if userPwd != csl.GetPassword() {
|
||||||
|
@ -307,7 +294,7 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case common.LoginTypeTelCode: // 手机验证码登录
|
case common.LoginTypeTelCode: // 手机验证码登录
|
||||||
if acc.Tel == username && acc.Platform == csl.GetPlatform() && acc.TagKey == tagkey {
|
if acc.Tel == csl.GetUsername() && acc.Platform == csl.GetPlatform() && acc.TagKey == tagkey {
|
||||||
if codeValid {
|
if codeValid {
|
||||||
// 更新密码
|
// 更新密码
|
||||||
raw := fmt.Sprintf("%v%v", bson.NewObjectId().Hex(), common.GetAppId())
|
raw := fmt.Sprintf("%v%v", bson.NewObjectId().Hex(), common.GetAppId())
|
||||||
|
@ -338,18 +325,6 @@ 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
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//密码错误
|
//密码错误
|
||||||
|
@ -374,7 +349,7 @@ func (this *CSLoginHandler) Process(s *netlib.Session, packetid int, data interf
|
||||||
SCLogin(s, sid, csl, acc, login_proto.OpResultCode_OPRC_Sucess, false)
|
SCLogin(s, sid, csl, acc, login_proto.OpResultCode_OPRC_Sucess, false)
|
||||||
|
|
||||||
// 标记当前玩家登录成功,断开其它连接
|
// 标记当前玩家登录成功,断开其它连接
|
||||||
lss := LoginStateMgrSington.LoginFinish(username, csl.GetPlatform(), sid, acc, tagkey)
|
lss := LoginStateMgrSington.LoginFinish(csl.GetUsername(), csl.GetPlatform(), sid, acc, tagkey)
|
||||||
if len(lss) != 0 {
|
if len(lss) != 0 {
|
||||||
for k, ls := range lss {
|
for k, ls := range lss {
|
||||||
ssDis := &login_proto.SSDisconnect{
|
ssDis := &login_proto.SSDisconnect{
|
||||||
|
|
|
@ -4,9 +4,7 @@ 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"
|
||||||
|
@ -41,20 +39,20 @@ 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验证
|
// token验证
|
||||||
claims, err := webapi.ParseJwtWithClaims([]byte(common.Config.AppId), t.Token)
|
//claims, err := webapi.ParseJwtWithClaims([]byte(common.Config.AppId), t.Token)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return 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"]
|
||||||
|
|
||||||
username := (claims.(jwt.MapClaims))["Username"].(string)
|
|
||||||
//expire := (claims.(jwt.MapClaims))["Exp"]
|
//expire := (claims.(jwt.MapClaims))["Exp"]
|
||||||
//timeStamp := (claims.(jwt.MapClaims))["Timestamp"]
|
//timeStamp := (claims.(jwt.MapClaims))["Timestamp"]
|
||||||
|
|
||||||
acc, retCode := model.AccountIsExist(username, username, t.GetPassword(), t.GetPlatform(),
|
acc, retCode := model.AccountIsExist(t.GetUsername(), t.GetUsername(), t.GetPassword(), t.GetPlatform(),
|
||||||
t.GetTimeStamp(), common.LoginTypePlatformToken, t.tagkey, false, t.codeValid)
|
t.GetTimeStamp(), t.GetLoginType(), t.tagkey, false, t.codeValid)
|
||||||
|
|
||||||
switch retCode {
|
switch retCode {
|
||||||
case common.LoginOk:
|
case common.LoginOk:
|
||||||
|
|
|
@ -2910,8 +2910,7 @@ func init() {
|
||||||
return common.ResponseTag_ParamError, jsonDataRsp
|
return common.ResponseTag_ParamError, jsonDataRsp
|
||||||
}
|
}
|
||||||
|
|
||||||
pack.Data.Url = fmt.Sprintf("%s?login_token=%s", model.GameParamData.PlatformClientAddr, tokenStr)
|
pack.Data.Url = fmt.Sprintf("%s?access_token=%s", model.GameParamData.PlatformClientAddr, tokenStr)
|
||||||
logger.Logger.Tracef("/api/platform/createUser pack.Data.Url : %v", pack.Data.Url)
|
|
||||||
|
|
||||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||||
acc, retCode := model.AccountIsExist(AccountInfo.Username, "", "", "1", AccountInfo.Timestamp,
|
acc, retCode := model.AccountIsExist(AccountInfo.Username, "", "", "1", AccountInfo.Timestamp,
|
||||||
|
|
Loading…
Reference in New Issue