mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2026-09-15 19:25:48 -04:00
feat(Core): expose needed cookie parts to controllers
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
|
using Core.Models;
|
||||||
|
|
||||||
namespace Core.Middlewares;
|
namespace Core.Middlewares;
|
||||||
|
|
||||||
public class AuthorizationMiddleware(RequestDelegate next)
|
public class AuthorizationMiddleware(RequestDelegate next)
|
||||||
{
|
{
|
||||||
public Task Invoke(HttpContext httpContext)
|
public Task Invoke(HttpContext httpContext, CookiePlayerData playerData)
|
||||||
{
|
{
|
||||||
var cookieHeader = httpContext.Request.Headers.Cookie.ToString();
|
var cookieHeader = httpContext.Request.Headers.Cookie.ToString();
|
||||||
|
|
||||||
@@ -22,6 +24,10 @@ public class AuthorizationMiddleware(RequestDelegate next)
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playerData.Uuid = httpContext.Request.Cookies["sid"]!.Split(":")[2];
|
||||||
|
playerData.Name = httpContext.Request.Cookies["user"]!;
|
||||||
|
playerData.Version = httpContext.Request.Cookies["version"]!;
|
||||||
|
|
||||||
return next(httpContext);
|
return next(httpContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -1,10 +1,13 @@
|
|||||||
using Core.Data;
|
using Core.Data;
|
||||||
using Core.Helpers;
|
|
||||||
using Core.Middlewares;
|
using Core.Middlewares;
|
||||||
|
using Core.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using AppConfig = Core.Helpers.AppConfig;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
builder.Services.AddScoped<CookiePlayerData>();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
|
|
||||||
var connectionString = builder.Configuration.GetValue<string>("Database");
|
var connectionString = builder.Configuration.GetValue<string>("Database");
|
||||||
|
|||||||
Reference in New Issue
Block a user