🐛 Fix user info not found panic

This commit is contained in:
LittleSheep 2024-12-22 14:43:02 +08:00
parent cd58e7a429
commit 8e1adfae9a

View File

@ -3,6 +3,7 @@ package ws
import ( import (
"context" "context"
"fmt" "fmt"
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory" "git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
"git.solsynth.dev/hypernet/nexus/pkg/nex" "git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec" "git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
@ -14,7 +15,11 @@ import (
) )
func Listen(c *websocket.Conn) { func Listen(c *websocket.Conn) {
user := c.Locals("nex_user").(sec.UserInfo) user, ok := c.Locals("nex_user").(sec.UserInfo)
if !ok {
c.Close()
return
}
// Push connection // Push connection
clientId := ClientRegister(user, c) clientId := ClientRegister(user, c)