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

@ -25,8 +25,6 @@ namespace Oqtane.Services
public async Task<Installation> IsInstalled()
{
// add antiforgerytoken header so that it is included on all HttpClient calls for the lifetime of the app
AddRequestHeader(Constants.AntiForgeryTokenHeaderName, _siteState.AntiForgeryToken);
var path = new Uri(_navigationManager.Uri).LocalPath.Substring(1);
return await GetJsonAsync<Installation>($"{ApiUrl}/installed/?path={WebUtility.UrlEncode(path)}");
}
@ -50,5 +48,14 @@ namespace Oqtane.Services
{
await PostJsonAsync($"{ApiUrl}/register?email={WebUtility.UrlEncode(email)}", true);
}
public void SetAntiForgeryTokenHeader(string antiforgerytokenvalue)
{
if (!string.IsNullOrEmpty(antiforgerytokenvalue))
{
AddRequestHeader(Constants.AntiForgeryTokenHeaderName, antiforgerytokenvalue);
}
}
}
}