mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-07-02 10:38:16 +00:00
feat: Enhance token validation in MobileControlWebsocketServer to handle missing tokens
This commit is contained in:
parent
ec7db1b510
commit
101d6c6e79
1 changed files with 5 additions and 3 deletions
|
|
@ -1154,10 +1154,12 @@ namespace PepperDash.Essentials.WebSocketServer
|
|||
|
||||
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";
|
||||
res.StatusCode = 401;
|
||||
var message = string.IsNullOrEmpty(token)
|
||||
? "Token is required"
|
||||
: "Token invalid or has expired";
|
||||
res.StatusCode = string.IsNullOrEmpty(token) ? 400 : 401;
|
||||
res.ContentType = "application/json";
|
||||
this.LogVerbose("{message}", message);
|
||||
body = Encoding.UTF8.GetBytes(message);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue