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{}
|
||||
defer func() {
|
||||
if user != nil && code != pb.ErrorCode_Success {
|
||||
if user != nil && code == pb.ErrorCode_Success {
|
||||
rsp.Data = user
|
||||
rsp.TimeNow = time.Now().Unix() // 设置服务器时间
|
||||
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
|
||||
} 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
|
||||
return
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
@ -68,9 +69,11 @@ func (this *User) GetUserSession(uid string) *pb.CacheUser {
|
||||
// 清除session
|
||||
func (this *User) CleanSession(session comm.IUserSession) {
|
||||
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.modelExpand.Del(session.GetUserId(), modules.SetDBMgoLog(false)) // 暂时不清
|
||||
this.modelExpand.Del(session.GetUserId(), db.SetDBMgoLog(false))
|
||||
this.modelSetting.Del(session.GetUserId(), db.SetDBMgoLog(false))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user