ext: HttpContext.GetUdid() over SID-mapping service
Mirrors how the translation middleware resolves the per-request UDID; needed by ToolController.Signup and the SteamSession find-or-link branch. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
using SVSim.Database.Models;
|
using SVSim.Database.Models;
|
||||||
|
using SVSim.EmulatedEntrypoint.Constants;
|
||||||
|
using SVSim.EmulatedEntrypoint.Services;
|
||||||
|
|
||||||
namespace SVSim.EmulatedEntrypoint.Extensions;
|
namespace SVSim.EmulatedEntrypoint.Extensions;
|
||||||
|
|
||||||
@@ -21,4 +23,18 @@ public static class HttpContextExtensions
|
|||||||
context.Items[ViewerItemName] = viewer;
|
context.Items[ViewerItemName] = viewer;
|
||||||
return viewer;
|
return viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves the client's UDID for this request by looking up the SID header in the
|
||||||
|
/// in-memory SID→UDID dict that <see cref="Middlewares.SessionidMappingMiddleware"/>
|
||||||
|
/// populates from the UDID header. Returns null when the SID isn't mapped (e.g. the
|
||||||
|
/// request didn't carry a UDID header at all, or carried an undecodable one).
|
||||||
|
/// </summary>
|
||||||
|
public static Guid? GetUdid(this HttpContext context)
|
||||||
|
{
|
||||||
|
string? sid = context.Request.Headers[NetworkConstants.SessionIdHeaderName];
|
||||||
|
if (sid is null) return null;
|
||||||
|
var sessionService = context.RequestServices.GetService<ShadowverseSessionService>();
|
||||||
|
return sessionService?.GetUdidFromSessionId(sid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user