Van normális bejelenkezési ablak

This commit is contained in:
2025-03-12 10:38:30 +01:00
parent 29e6efc9e0
commit c9ffad0d91
8 changed files with 117 additions and 5 deletions
+11
View File
@@ -19,6 +19,7 @@ builder.Services.AddMemoryCache();
builder.Services.AddHttpContextAccessor();
builder.Services.AddHttpClient();
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.AddScoped<IBaseStockService, BaseStockService>();
builder.Host.UseSerilog();
@@ -76,7 +77,17 @@ app.MapPost("/login", async ([FromBody] UserDTO userDTO, JwtService jwtService,
});
app.MapGet("/secure-data", [Authorize] () => "This is protected data");
app.Use(async (context, next) =>
{
if (string.IsNullOrEmpty(context.User?.Identity?.Name) &&
context.Request.Path == "/")
{
context.Response.Redirect("/Account/Login");
return;
}
await next();
});
app.MapRazorPages();
app.Run();