feat: Enhance token validation in MobileControlWebsocketServer to handle missing tokens

This commit is contained in:
Neil Dorin 2026-05-20 13:30:42 -06:00
parent ec7db1b510
commit 101d6c6e79

View file

@ -1154,10 +1154,12 @@ namespace PepperDash.Essentials.WebSocketServer
byte[] body; byte[] body;
if (!UiClientContexts.TryGetValue(token, out UiClientContext clientContext)) if (string.IsNullOrEmpty(token) || !UiClientContexts.TryGetValue(token, out UiClientContext clientContext))
{ {
var message = "Token invalid or has expired"; var message = string.IsNullOrEmpty(token)
res.StatusCode = 401; ? "Token is required"
: "Token invalid or has expired";
res.StatusCode = string.IsNullOrEmpty(token) ? 400 : 401;
res.ContentType = "application/json"; res.ContentType = "application/json";
this.LogVerbose("{message}", message); this.LogVerbose("{message}", message);
body = Encoding.UTF8.GetBytes(message); body = Encoding.UTF8.GetBytes(message);