session清理
This commit is contained in:
parent
18faf227be
commit
19ccac6357
@ -33,7 +33,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
|
|||||||
|
|
||||||
rsp := &pb.UserLoginResp{}
|
rsp := &pb.UserLoginResp{}
|
||||||
defer func() {
|
defer func() {
|
||||||
if user != nil && code != pb.ErrorCode_Success {
|
if user != nil && code == pb.ErrorCode_Success {
|
||||||
rsp.Data = user
|
rsp.Data = user
|
||||||
rsp.TimeNow = time.Now().Unix() // 设置服务器时间
|
rsp.TimeNow = time.Now().Unix() // 设置服务器时间
|
||||||
err = session.SendMsg(string(this.module.GetType()), UserSubTypeLogin, rsp)
|
err = session.SendMsg(string(this.module.GetType()), UserSubTypeLogin, rsp)
|
||||||
@ -68,7 +68,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
|
|||||||
}
|
}
|
||||||
isNewUser = true
|
isNewUser = true
|
||||||
} else {
|
} else {
|
||||||
if cu := this.module.modelSession.getUserSession(user.Uid); cu != nil {
|
if cu := this.module.modelSession.getUserSession(user.Uid); cu.SessionId != "" {
|
||||||
code = pb.ErrorCode_UserLogined
|
code = pb.ErrorCode_UserLogined
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
@ -68,9 +69,11 @@ func (this *User) GetUserSession(uid string) *pb.CacheUser {
|
|||||||
// 清除session
|
// 清除session
|
||||||
func (this *User) CleanSession(session comm.IUserSession) {
|
func (this *User) CleanSession(session comm.IUserSession) {
|
||||||
this.modelUser.updateOfflineTime(session.GetUserId())
|
this.modelUser.updateOfflineTime(session.GetUserId())
|
||||||
this.modelSession.Del(session.GetUserId(), db.SetDBMgoLog(false))
|
sId := fmt.Sprintf("%s-%s", comm.RDS_SESSION, session.GetUserId())
|
||||||
|
this.modelSession.Del(sId, db.SetDBMgoLog(false))
|
||||||
|
this.modelSession.DelListlds(comm.RDS_SESSION, session.GetUserId())
|
||||||
this.modelUser.Del(session.GetUserId(), db.SetDBMgoLog(false))
|
this.modelUser.Del(session.GetUserId(), db.SetDBMgoLog(false))
|
||||||
//this.modelExpand.Del(session.GetUserId(), modules.SetDBMgoLog(false)) // 暂时不清
|
this.modelExpand.Del(session.GetUserId(), db.SetDBMgoLog(false))
|
||||||
this.modelSetting.Del(session.GetUserId(), db.SetDBMgoLog(false))
|
this.modelSetting.Del(session.GetUserId(), db.SetDBMgoLog(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user