diff --git a/EnotaryoPH/EnotaryoPH.Web/Assets/js/Page/_Page.js b/EnotaryoPH/EnotaryoPH.Web/Assets/js/Page/_Page.js new file mode 100644 index 0000000..58ae1ba --- /dev/null +++ b/EnotaryoPH/EnotaryoPH.Web/Assets/js/Page/_Page.js @@ -0,0 +1,24 @@ +jfa.page = (function () { + function _getAlertContainer() { + return document.getElementById("ContainerAlert"); + } + + function _getAlertTemplate() { + return document.getElementById("AlertTemplate").cloneNode(true); + } + + function _getAntiForgeryToken() { + return window.top.document.querySelector("[name='__RequestVerificationToken']")?.value; + } + + function reload() { + window.location.reload(); + } + + return { + getAlertContainer: _getAlertContainer, + getAlertTemplate: _getAlertTemplate, + getAntiForgeryToken: _getAntiForgeryToken, + reload: reload + }; +})(); \ No newline at end of file diff --git a/EnotaryoPH/EnotaryoPH.Web/Assets/js/Utilities/Request/_Request.js b/EnotaryoPH/EnotaryoPH.Web/Assets/js/Utilities/Request/_Request.js index d5dc0b9..f6713dc 100644 --- a/EnotaryoPH/EnotaryoPH.Web/Assets/js/Utilities/Request/_Request.js +++ b/EnotaryoPH/EnotaryoPH.Web/Assets/js/Utilities/Request/_Request.js @@ -10,7 +10,7 @@ headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', - 'X-XSRF-TOKEN': jfa.page.getAntiForgeryToken() + 'RequestVerificationToken': jfa.page.getAntiForgeryToken() }, body: data ? JSON.stringify(data) : data }); diff --git a/EnotaryoPH/EnotaryoPH.Web/Pages/Shared/_AntiForgeryPartial.cshtml b/EnotaryoPH/EnotaryoPH.Web/Pages/Shared/_AntiForgeryPartial.cshtml new file mode 100644 index 0000000..07b257d --- /dev/null +++ b/EnotaryoPH/EnotaryoPH.Web/Pages/Shared/_AntiForgeryPartial.cshtml @@ -0,0 +1,7 @@ +@using Microsoft.AspNetCore.Antiforgery +@inject Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor +@inject IAntiforgery antiforgery +@{ + var token = antiforgery.GetAndStoreTokens(httpContextAccessor.HttpContext).RequestToken; +} + \ No newline at end of file diff --git a/EnotaryoPH/EnotaryoPH.Web/Pages/Shared/_Layout.cshtml b/EnotaryoPH/EnotaryoPH.Web/Pages/Shared/_Layout.cshtml index 7d9d470..cfb9570 100644 --- a/EnotaryoPH/EnotaryoPH.Web/Pages/Shared/_Layout.cshtml +++ b/EnotaryoPH/EnotaryoPH.Web/Pages/Shared/_Layout.cshtml @@ -43,7 +43,7 @@ @RenderBody() - +