-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
user.HasPermission(UserPermissions.PermissonName) is not a problem in UserManagement project but is not working for EasyStock which use http to connect to web api project to to get the data.
Another approach to solve is below. It is working but it is a little bit slow.
// Fetch permissions during initialization or when needed
var result = await httpClient.GetAsync("api/Authenticate/getuserpermissions");
if (result.IsSuccessStatusCode)
{
var contentTemp = await result.Content.ReadAsStringAsync();
roles = JsonConvert.DeserializeObject<List<string>>(contentTemp);
}
// Use roles in your conditional checks - NavMenu
@if (roles != null && roles.Contains("AccessPageLevelOne"))
{
<FluentNavLink Href="contactList" Icon="@(new Icons.Regular.Size20.WeatherPartlyCloudyDay())" IconColor="Color.Accent">Contact List</FluentNavLink>
<FluentNavLink Href="contactCreate" Icon="@(new Icons.Regular.Size20.WeatherPartlyCloudyDay())" IconColor="Color.Accent">EasyStock Contact</FluentNavLink>
}
Metadata
Metadata
Assignees
Labels
No labels