Van normális bejelenkezési ablak
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user