I have to obtain quite in every "page" (razor component) the EmployeeId of the logged User.
I have a MyComponentBase class that derives from ComponentBase that makes the query on the DB based on the domain username (windows security) and every page derives from this MyComponentBase
protected override async Task OnInitializedAsync()
{
UserName = (await AuthenticationStateTask).User.Identity.Name;
CurrentEmployee = await EmployeeService.GetByShortName(UserName);
if (CurrentEmployee == null)
{
NavigationManager.NavigateTo("/accessdenied");
}
//... EmployeeId = CurrentEmployee.EmployeeId; ecc...
Obviously this is a waste, but I cannot find where to put the code (in a middleware? program.cs? ) and where to store the data (ideally not only the ID but a more complex object with more info, its Roles collection, etc.)
Thanks in advance
