fix #1691 - AntiForgeryToken header not being set during startup

This commit is contained in:
Shaun Walker
2021-09-27 08:44:16 -04:00
parent 82ae9409f1
commit 4bfb5d9f34
3 changed files with 22 additions and 5 deletions

View File

@ -47,11 +47,13 @@
protected override async Task OnParametersSetAsync()
{
SiteState.AntiForgeryToken = AntiForgeryToken;
InstallationService.SetAntiForgeryTokenHeader(AntiForgeryToken);
_installation = await InstallationService.IsInstalled();
if (_installation.Alias != null)
{
SiteState.Alias = _installation.Alias;
SiteState.AntiForgeryToken = AntiForgeryToken;
}
else
{
@ -68,8 +70,10 @@
{
// parameter values are not set when running on WebAssembly (seems to be a .NET 5 bug) - need to retrieve using JSInterop
var interop = new Interop(JSRuntime);
AntiForgeryToken = await interop.GetElementByName(Constants.RequestVerificationToken);
SiteState.AntiForgeryToken = AntiForgeryToken;
SiteState.AntiForgeryToken = await interop.GetElementByName(Constants.RequestVerificationToken);
InstallationService.SetAntiForgeryTokenHeader(SiteState.AntiForgeryToken);
Runtime = await interop.GetElementByName("app_runtime");
RenderMode = await interop.GetElementByName("app_rendermode");
}