I have a main layout with a sidebar that differs for authorized and non-authorized users. The place which I want to update looks like that
<AuthorizeView>
<Authorized>
// Personal information matches in this component (it's just one more div this some code in it)
<UserInfo />
</Authorized>
<NotAuthorized>
<div class="sidebar-unathorized">
<span>
To get all privileges, <a href="/register"><strong>register</strong></a> or <a href="/login"><strong>login</strong></a> please
</span>
</div>
</NotAuthorized>
</AuthorizeView>
After user passes authorization I want him to see his personal information so in my login method I do some stuff like
public async void HandleValidSubmit()
{
...
((CustomAuthenticationStateProvider)authenticationStateProvider).AuthenticateUser(authorizedUser);
navigationManager.NavigateTo("/");
//here I want to update the layout
...
return;
}
and in my CustomAuthenticationStateProvider after setting the current user I do
NotifyAuthenticationStateChanged(Task.FromResult(new AuthenticationState(user)));
which i hoped would be enough to all components which are authorization-based to update.
But it's not. I tried StateHasChanged() method but understanably it doesn't work like that cause it just updates the component which it's triggered from. But if u manually reload the page after logging in all will be ok. Any ideas how can I update the layout from code?