zhou.xiaoning %!s(int64=2) %!d(string=hai) anos
pai
achega
6dd3c849bd
Modificáronse 1 ficheiros con 11 adicións e 2 borrados
  1. 11 2
      service/account/login.go

+ 11 - 2
service/account/login.go

@@ -219,7 +219,17 @@ func buildRedisLoginInfo(loginaccount accountModel.Loginaccount, addr string, gr
 	if client.Clients == nil {
 		client.Clients = make(map[int]*client.Client, 0)
 	}
-	delete(client.Clients, claims.SessionID)
+	// 这里应该按loginid和group把之前的client删除掉
+	// delete(client.Clients, s)
+	targetKeys := make([]int, 0)
+	for key, item := range client.Clients {
+		if item.LoginID == loginLogin.LoginID && item.Group == loginLogin.Group {
+			targetKeys = append(targetKeys, key)
+		}
+	}
+	for _, k := range targetKeys {
+		delete(client.Clients, k)
+	}
 	client.Clients[claims.SessionID] = &client.Client{LoginRedis: loginLogin}
 
 	return
@@ -269,7 +279,6 @@ func RestoreLoginWithToken(loginID int, group int, token string) (err error) {
 	for _, k := range targetKeys {
 		delete(client.Clients, k)
 	}
-
 	client.Clients[s] = &client.Client{LoginRedis: loginLogin}
 
 	return