add tests, 05 is broken
This commit is contained in:
+22
-5
@@ -146,12 +146,29 @@ func handleUnauthenticatedMessage(ctx context.Context, client *Client, clientMes
|
||||
|
||||
clientFromCache, err := CacheGetClientById(clientId)
|
||||
if err != nil {
|
||||
var msg = map[string]any{
|
||||
"from": "server",
|
||||
"error": "invalid token",
|
||||
// Not in cache — load from database
|
||||
dbClient := &Client{Id: clientId}
|
||||
err = DbSetClientByIdWithoutGroups(ctx, dbClient)
|
||||
if err != nil {
|
||||
var msg = map[string]any{
|
||||
"from": "server",
|
||||
"error": "invalid client data",
|
||||
}
|
||||
sendMessageCloseIfTimeout(client, &msg)
|
||||
return false
|
||||
}
|
||||
sendMessageCloseIfTimeout(client, &msg)
|
||||
return false
|
||||
err = DbSetClientGroups(ctx, dbClient)
|
||||
if err != nil {
|
||||
var msg = map[string]any{
|
||||
"from": "server",
|
||||
"error": "invalid client data",
|
||||
}
|
||||
sendMessageCloseIfTimeout(client, &msg)
|
||||
return false
|
||||
}
|
||||
dbClient.WsConn = client.WsConn
|
||||
CacheSaveClient(dbClient)
|
||||
clientFromCache = dbClient
|
||||
}
|
||||
|
||||
*client = *clientFromCache
|
||||
|
||||
Reference in New Issue
Block a user