fix
This commit is contained in:
parent
59edb394fa
commit
0657307265
|
@ -7,6 +7,7 @@ import (
|
|||
"fusenapi/server/websocket/internal/logic"
|
||||
"fusenapi/server/websocket/internal/svc"
|
||||
"fusenapi/server/websocket/internal/types"
|
||||
"fusenapi/utils/auth"
|
||||
"github.com/google/uuid"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
@ -54,11 +55,11 @@ func DataTransferHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
defer conn.Close()
|
||||
rsp := types.DataTransferRsp{}
|
||||
// 解析JWT token,并对空用户进行判断
|
||||
/*claims, err := svcCtx.ParseJwtToken(r)
|
||||
claims, err := svcCtx.ParseJwtToken(r)
|
||||
// 如果解析JWT token出错,则返回未授权的JSON响应并记录错误消息
|
||||
if err != nil {
|
||||
rsp.MsgType = constants.WEBSOCKET_UNAUTH
|
||||
rsp.Message = "unAuth"
|
||||
rsp.T = constants.WEBSOCKET_UNAUTH
|
||||
rsp.D = "unAuth"
|
||||
b, _ := json.Marshal(rsp)
|
||||
_ = conn.WriteMessage(websocket.TextMessage, b)
|
||||
return
|
||||
|
@ -68,20 +69,20 @@ func DataTransferHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
_, err = auth.GetUserInfoFormMapClaims(claims)
|
||||
// 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息
|
||||
if err != nil {
|
||||
rsp.MsgType = constants.WEBSOCKET_UNAUTH
|
||||
rsp.Message = "unAuth!!"
|
||||
rsp.T = constants.WEBSOCKET_UNAUTH
|
||||
rsp.D = "unAuth!!"
|
||||
b, _ := json.Marshal(rsp)
|
||||
_ = conn.WriteMessage(websocket.TextMessage, b)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// 如果claims为nil,则认为用户身份为白板用户
|
||||
rsp.MsgType = constants.WEBSOCKET_UNAUTH
|
||||
rsp.Message = "unAuth!!!"
|
||||
rsp.T = constants.WEBSOCKET_UNAUTH
|
||||
rsp.D = "unAuth!!!"
|
||||
b, _ := json.Marshal(rsp)
|
||||
_ = conn.WriteMessage(websocket.TextMessage, b)
|
||||
return
|
||||
}*/
|
||||
}
|
||||
//生成连接唯一标识
|
||||
flag := uuid.New().String() + time.Now().Format("20060102150405")
|
||||
ws := wsConnectItem{
|
||||
|
|
Loading…
Reference in New Issue
Block a user