* Turned off Login as it is not working

This commit is contained in:
2025-03-01 06:35:28 +01:00
parent b8fbb789ad
commit f321677447
19 changed files with 122 additions and 154 deletions

View File

@@ -7,7 +7,6 @@ namespace FaKrosnoApi.Controllers
{
[ApiController]
[Route("api/[controller]")]
[Authorize]
public class ErrorLogController(IErrorLogService service) : Controller
{
[HttpGet]

View File

@@ -7,7 +7,6 @@ namespace FaKrosnoApi.Controllers
{
[ApiController]
[Route("api/[controller]")]
[Authorize]
public class ScheduleOrdersController(IScheduleOrderService service) : Controller
{
[HttpGet]

View File

@@ -4,6 +4,8 @@ using OrdersManagementDataModel.Services;
namespace FaKrosnoApi.Controllers;
[ApiController]
[Route("api/[controller]")]
public class UserRolesController(IUserRoleService service) : Controller
{
[HttpGet]

View File

@@ -32,21 +32,21 @@ builder.Services.Configure<JobSettingsModel>(builder.Configuration.GetSection("J
builder.WebHost.UseUrls("http://*:5001");
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
ValidIssuer = builder.Configuration["Jwt:Issuer"],
ValidAudience = builder.Configuration["Jwt:Audience"],
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"] ?? string.Empty)),
NameClaimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"
};
});
// builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
// .AddJwtBearer(options =>
// {
// options.TokenValidationParameters = new TokenValidationParameters
// {
// ValidateIssuer = true,
// ValidateAudience = true,
// ValidateLifetime = true,
// ValidateIssuerSigningKey = true,
// ValidIssuer = builder.Configuration["Jwt:Issuer"],
// ValidAudience = builder.Configuration["Jwt:Audience"],
// IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"] ?? string.Empty)),
// NameClaimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"
// };
// });
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();

View File

@@ -20,21 +20,6 @@
<body>
<Routes @rendermode="@InteractiveServer" />
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
<h3>Brak autoryzacji</h3>
<p><a href="/login">Zaloguj się</a></p>
</NotAuthorized>
</AuthorizeRouteView>
</Found>
<NotFound>
<p>Strona nie znaleziona.</p>
</NotFound>
</Router>
</CascadingAuthenticationState>
<script src="_framework/blazor.web.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.0.1/chart.umd.js" integrity="sha512-gQhCDsnnnUfaRzD8k1L5llCCV6O9HN09zClIzzeJ8OJ9MpGmIlCxm+pdCkqTwqJ4JcjbojFr79rl2F1mzcoLMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

View File

@@ -16,23 +16,23 @@
<img src="logo.svg" class="me-2" width="35" height="35" alt="Icon">
<h3 class="text-primary m-0">FA Krosno Manager</h3>
</div>
<div class="d-flex align-items-center">
@if (IsAuthenticated)
{
<span class="me-2">Jesteś zalogowany jako <strong>@UserName</strong></span>
<SfButton CssClass="e-primary" IsPrimary="true" @onclick="Logout">Wyloguj</SfButton>
}
else
{
<a href="/login" class="text-muted">Zaloguj</a>
}
</div>
@* <div class="d-flex align-items-center"> *@
@* @if (IsAuthenticated) *@
@* { *@
@* <span class="me-2">Jesteś zalogowany jako <strong>@UserName</strong></span> *@
@* <SfButton CssClass="e-primary" IsPrimary="true" @onclick="Logout">Wyloguj</SfButton> *@
@* } *@
@* else *@
@* { *@
@* <a href="/login" class="text-muted">Zaloguj</a> *@
@* } *@
@* </div> *@
</div>
<div class="row gx-1 flex-grow-1">
<div class="col-auto custom-menu-width">
<SfMenu TValue="MenuItem" HamburgerMode="true" Orientation="Vertical" Title="Menu">
<MenuItems>
<MenuItem Text="Zamówienia DELFOR" Url="/ScheduleOrders" IconCss="fa-solid fa-landmark"></MenuItem>
<MenuItem Text="Zamówienia DELFOR" Url="/" IconCss="fa-solid fa-landmark"></MenuItem>
<MenuItem Text="Zamówienia klienta EDI" Url="/EdiCustomerOrders" IconCss="fa-solid fa-list-check"></MenuItem>
<MenuItem Text="Zamówienia klienta" Url="/CustomerOrders" IconCss="fa-solid fa-database"></MenuItem>
@if (UserName == "pkus")
@@ -64,11 +64,11 @@
protected override void OnInitialized()
{
ClaimsPrincipal currentUser = AuthenticationStateProvider.GetCurrentUser();
IsAuthenticated = currentUser.Identity?.IsAuthenticated == true;
UserName = currentUser.Identity?.Name ?? "Nieznany użytkownik";
AuthenticationStateProvider.AuthenticationStateChanged += OnAuthenticationStateChanged;
// ClaimsPrincipal currentUser = AuthenticationStateProvider.GetCurrentUser();
// IsAuthenticated = currentUser.Identity?.IsAuthenticated == true;
// UserName = currentUser.Identity?.Name ?? "Nieznany użytkownik";
//
// AuthenticationStateProvider.AuthenticationStateChanged += OnAuthenticationStateChanged;
}
private async void OnAuthenticationStateChanged(Task<AuthenticationState> task)

View File

@@ -1,7 +1,5 @@
@page "/Admin/Scheduler"
@attribute [Authorize]
@using System.Security.Claims
@using Microsoft.AspNetCore.Authorization
@using OrdersManagementDataModel.Dtos
@@ -60,17 +58,17 @@
{
if (firstRender)
{
ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
if (currentUser.Identity?.IsAuthenticated == false || currentUser.Identity?.Name != "pkus")
{
NavigationManager.NavigateTo("/Unauthorized");
}
else
{
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
//
// if (currentUser.Identity?.IsAuthenticated == false || currentUser.Identity?.Name != "pkus")
// {
// NavigationManager.NavigateTo("/Unauthorized");
// }
// else
// {
await LoadTasks();
StateHasChanged();
}
// }
}
}

View File

@@ -1,7 +1,5 @@
@page "/admin/UsersManager"
@attribute [Authorize]
@using System.Security.Claims
@using Microsoft.AspNetCore.Authorization
@using OrdersManagementDataModel.Dtos
@@ -136,19 +134,19 @@
if (firstRender)
{
Visibility = false;
ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
if (currentUser.Identity?.IsAuthenticated == false || currentUser.Identity?.Name != "pkus")
{
NavigationManager.NavigateTo("/Unauthorized");
}
else
{
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
//
// if (currentUser.Identity?.IsAuthenticated == false || currentUser.Identity?.Name != "pkus")
// {
// NavigationManager.NavigateTo("/Unauthorized");
// }
// else
// {
await LoadUsers();
await LoadRoles();
//await LoadFunctions();
StateHasChanged();
}
// }
}
}

View File

@@ -1,7 +1,5 @@
@page "/CustomerOrder/{CustomerOrderId:guid}"
@attribute [Authorize]
@inject CustomerOrderService CustomerOrderService
@inject ScheduleOrderService ScheduleOrderService
@inject NavigationManager NavigationManager
@@ -224,14 +222,14 @@
StateHasChanged();
_isVisible = false;
ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
if (currentUser.Identity?.IsAuthenticated == false)
{
NavigationManager.NavigateTo("/Unauthorized");
}
else
{
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
//
// if (currentUser.Identity?.IsAuthenticated == false)
// {
// NavigationManager.NavigateTo("/Unauthorized");
// }
// else
// {
CustomerOrderDto? customerOrder = await CustomerOrderService.GetCustomerOrderAsync(CustomerOrderId);
if (customerOrder != null)
@@ -239,7 +237,9 @@
CustomerOrderDto = customerOrder;
_customerOrderLines = CustomerOrderDto.CustomerOrderLines.ToList() ?? [];
}
}
StateHasChanged();
// }
}
}

View File

@@ -1,7 +1,5 @@
@page "/CustomerOrders"
@attribute [Authorize]
@inject CustomerOrderService CustomerOrderService
@inject NavigationManager NavigationManager
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
@@ -91,19 +89,19 @@
{
if (firstRender)
{
ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
if (currentUser.Identity?.IsAuthenticated == false)
{
NavigationManager.NavigateTo("/Unauthorized");
}
else
{
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
//
// if (currentUser.Identity?.IsAuthenticated == false)
// {
// NavigationManager.NavigateTo("/Unauthorized");
// }
// else
// {
_customerOrders = await CustomerOrderService.GetCustomerOrdersAsync() ?? new List<CustomerOrderDto>();
_customerOrders = _customerOrders.OrderByDescending(x => x.CreateDate).ToList();
StateHasChanged();
}
// }
}
}

View File

@@ -1,7 +1,5 @@
@page "/EdiCustomerOrder/{CustomerOrderId:guid}"
@attribute [Authorize]
@inject EdiCustomerOrderService EdiCustomerOrderService
@inject NavigationManager NavigationManager
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
@@ -197,19 +195,20 @@
{
if (firstRender)
{
ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
if (currentUser.Identity?.IsAuthenticated == false)
{
NavigationManager.NavigateTo("/Unauthorized");
}
else
{
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
//
// if (currentUser.Identity?.IsAuthenticated == false)
// {
// NavigationManager.NavigateTo("/Unauthorized");
// }
// else
// {
EdiCustomerOrderDto? ediCustomerOrder = await EdiCustomerOrderService.GetEdiCustomerOrderAsync(CustomerOrderId);
EdiCustomerOrderDto = ediCustomerOrder;
_ediCustomerOrderLines = ediCustomerOrder?.EdiCustomerOrderLines.ToList() ?? [];
}
StateHasChanged();
// }
}
}

View File

@@ -1,7 +1,5 @@
@page "/EdiCustomerOrders"
@attribute [Authorize]
@inject EdiCustomerOrderService EdiCustomerOrderService
@inject NavigationManager NavigationManager
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
@@ -34,7 +32,7 @@
{
<div class="row mb-4">
<div class="col-md-12">
<SfButton CssClass="btn-primary" @onclick="SendOrderToSyteLine">@_text</SfButton>
<SfButton CssClass="e-primary" IsPrimary="true" @onclick="SendOrderToSyteLine">@_text</SfButton>
</div>
</div>
}
@@ -146,16 +144,16 @@
{
if (firstRender)
{
ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
if (currentUser.Identity?.IsAuthenticated == false)
{
NavigationManager.NavigateTo("/Unauthorized");
}
else
{
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
//
// if (currentUser.Identity?.IsAuthenticated == false)
// {
// NavigationManager.NavigateTo("/Unauthorized");
// }
// else
// {
await LoadData();
}
// }
}
}

View File

@@ -1,7 +1,5 @@
@page "/login"
@attribute [AllowAnonymous]
@using Microsoft.AspNetCore.Authorization
@using OrdersManagement.Models
@using Syncfusion.Blazor.Inputs
@@ -79,7 +77,7 @@
}
</CardContent>
<CardFooter>
<small class="text-muted">Orders Management System © @(DateTime.Now.Year)</small>
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
</CardFooter>
</SfCard>
</div>

View File

@@ -1,7 +1,6 @@
@page "/"
@page "/Main"
@using Microsoft.AspNetCore.Authorization
@attribute [AllowAnonymous]
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
@inject NavigationManager NavigationManager

View File

@@ -1,5 +1,4 @@
@page "/ScheduleOrder/{ScheduleOrderId:int}"
@attribute [Authorize]
@using System.Security.Claims
@using Microsoft.AspNetCore.Authorization
@@ -128,14 +127,14 @@
{
if (firstRender)
{
ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
if (currentUser.Identity?.IsAuthenticated == false)
{
NavigationManager.NavigateTo("/Unauthorized");
}
else
{
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
//
// if (currentUser.Identity?.IsAuthenticated == false)
// {
// NavigationManager.NavigateTo("/Unauthorized");
// }
// else
// {
ScheduleOrderDto = await ScheduleOrderService.GetScheduleOrderAsync(ScheduleOrderId);
_scheduleOrderDetails = ScheduleOrderDto?.ScheduleOrderDetails;
@@ -149,7 +148,7 @@
scheduleOrderDetailDto.RecipientName = ScheduleOrderDto?.RecipientName;
scheduleOrderDetailDto.PurchaserName = ScheduleOrderDto?.PurchaserCode;
}
}
// }
StateHasChanged();
}

View File

@@ -1,6 +1,4 @@
@page "/ScheduleOrders"
@attribute [Authorize]
@page "/"
@using System.Security.Claims
@using Microsoft.AspNetCore.Authorization
@@ -20,17 +18,17 @@
{
if (firstRender)
{
ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
if (currentUser.Identity?.IsAuthenticated == false)
{
NavigationManager.NavigateTo("/Unauthorized");
}
else
{
// ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
//
// if (currentUser.Identity?.IsAuthenticated == false)
// {
// NavigationManager.NavigateTo("/Unauthorized");
// }
// else
// {
_scheduleOrders = await FetchScheduleOrdersAsync();
StateHasChanged();
}
// }
}
}

View File

@@ -95,7 +95,7 @@
</SfGrid>
</CardContent>
<CardFooter>
<small class="text-muted">Orders Management System © @(DateTime.Now.Year)</small>
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
</CardFooter>
</SfCard>
</div>

View File

@@ -1,8 +1,6 @@
@page "/Unauthorized"
@using Microsoft.AspNetCore.Authorization
@attribute [AllowAnonymous]
@using Syncfusion.Blazor.Cards
@using Syncfusion.Blazor.Buttons
@@ -22,7 +20,7 @@
</SfButton>
</CardContent>
<CardFooter>
<small class="text-muted">Orders Management System © @(DateTime.Now.Year)</small>
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
</CardFooter>
</SfCard>
</div>

View File

@@ -15,7 +15,7 @@ public class ServiceBase<T> where T : class
protected async Task<IEnumerable<T>?> GetListAsync(string request)
{
Configure();
//Configure();
var response = await _httpClient.GetAsync(request);
response.EnsureSuccessStatusCode();
@@ -24,7 +24,7 @@ public class ServiceBase<T> where T : class
protected async Task<T?> GetEntityAsync(string request)
{
Configure();
//Configure();
var response = await _httpClient.GetAsync(request);
response.EnsureSuccessStatusCode();
@@ -33,7 +33,7 @@ public class ServiceBase<T> where T : class
protected async Task<HttpResponseMessage> PostAsync(string request)
{
Configure();
//Configure();
var response = await _httpClient.PostAsync(request, null);
response.EnsureSuccessStatusCode();
@@ -42,7 +42,7 @@ public class ServiceBase<T> where T : class
protected async Task<HttpResponseMessage> PostAsJsonAsync(string request, T obj)
{
Configure();
//Configure();
var response = await _httpClient.PostAsJsonAsync(request, obj);
response.EnsureSuccessStatusCode();
@@ -51,7 +51,7 @@ public class ServiceBase<T> where T : class
protected async Task<HttpResponseMessage> PostAsJsonAsync(string request, object obj)
{
Configure();
//Configure();
var response = await _httpClient.PostAsJsonAsync(request, obj);
response.EnsureSuccessStatusCode();
@@ -60,7 +60,7 @@ public class ServiceBase<T> where T : class
protected async Task<HttpResponseMessage> PutAsJsonAsync(string request, T obj)
{
Configure();
//Configure();
var response = await _httpClient.PutAsJsonAsync(request, obj);
response.EnsureSuccessStatusCode();
@@ -69,7 +69,7 @@ public class ServiceBase<T> where T : class
protected async Task<HttpResponseMessage> DeleteAsync(string request)
{
Configure();
//Configure();
var response = await _httpClient.DeleteAsync(request);
response.EnsureSuccessStatusCode();