utilizzo metodo nuovo claims x nav menu

This commit is contained in:
zaccaria.majid
2023-05-29 09:15:49 +02:00
parent c10327cdb0
commit 9b80e7b25c
6 changed files with 38 additions and 11 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>WebDoorCreator - Egalware</i>
<h4>Version: 0.9.2305.2710</h4>
<h4>Version: 0.9.2305.2908</h4>
<br /> Release note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2305.2710
0.9.2305.2908
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2305.2710</version>
<version>0.9.2305.2908</version>
<url>http://nexus.steamware.net/repository/SWS/WDC/stable/WDC.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/WDC/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>
@@ -73,7 +73,7 @@
{
@if (compToShow != null)
{
<div>@compToShow.CompanyName</div>
<input class="form-control form-control-sm" value="@compToShow.CompanyName" disabled/>
}
}
}
@@ -22,6 +22,7 @@ namespace WebDoorCreator.UI.Components.Gen
public EventCallback<Dictionary<string, Dictionary<string, string>>> E_VocLemmas { get; set; }
public List<CompanyModel> listCompanies { get; set; } = new List<CompanyModel>();
protected List<System.Security.Claims.Claim>? userClaims { get; set; } = null;
public List<string> listRecord { get; set; } = new List<string>();
@@ -195,7 +196,7 @@ namespace WebDoorCreator.UI.Components.Gen
compToShow = listCompanies?.FirstOrDefault()!;
}
userCurrCompany = compToShow.CompanyId;
}
}
protected override async Task OnInitializedAsync()
{
@@ -230,14 +231,15 @@ namespace WebDoorCreator.UI.Components.Gen
{
// reset preliminare
listRecord = new List<string>();
listCompanies = new List<CompanyModel>();
//listCompanies = new List<CompanyModel>();
if (!NavManager.Uri.Contains("UserAdmin"))
{
if (!string.IsNullOrEmpty(userId) && string.IsNullOrEmpty(userRole))
{
// FARE!!! rivedere con await WDCUsrServ.UserDataGetById(userId);
var user = await _userManager.FindByNameAsync(userId);
#if false
var user = await _userManager.FindByNameAsync(userId);
var roleList = await _userManager.GetRolesAsync(user);
if (roleList != null)
@@ -278,10 +280,35 @@ namespace WebDoorCreator.UI.Components.Gen
}
compToShow = listCompanies?.FirstOrDefault()!;
}
}
fixSelCompany();
userClaimsList = listRecord;
}
}
#endif
var obj = await WDCUService.UserDataGetById(user.Id);
if (obj != null)
{
userClaims = obj.Claims.ToList();
if (userClaims != null)
{
if (obj.Roles.Contains("SuperAdmin"))
{
listCompanies = await WDCService.CompanyGetByKey(0);
}
else
{
foreach (var item in obj.Claims.ToList())
{
List<CompanyModel> rawComp = await WDCService.CompanyGetByKey(int.Parse(item.Value));
if (rawComp != null)
{
CompanyModel comp2Add = rawComp?.FirstOrDefault()!;
listCompanies.Add(comp2Add);
}
}
}
}
}
fixSelCompany();
userClaimsList = listRecord;
}
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>0.9.2305.2710</Version>
<Version>0.9.2305.2908</Version>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-WebDoorCreator.UI-dfe95fed-1398-4144-bd43-8b3a765d6608</UserSecretsId>
</PropertyGroup>