anti forgery
This commit is contained in:
parent
107c4ef2d6
commit
01705c86fe
24
EnotaryoPH/EnotaryoPH.Web/Assets/js/Page/_Page.js
Normal file
24
EnotaryoPH/EnotaryoPH.Web/Assets/js/Page/_Page.js
Normal file
@ -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
|
||||||
|
};
|
||||||
|
})();
|
@ -10,7 +10,7 @@
|
|||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-XSRF-TOKEN': jfa.page.getAntiForgeryToken()
|
'RequestVerificationToken': jfa.page.getAntiForgeryToken()
|
||||||
},
|
},
|
||||||
body: data ? JSON.stringify(data) : data
|
body: data ? JSON.stringify(data) : data
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
@using Microsoft.AspNetCore.Antiforgery
|
||||||
|
@inject Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor
|
||||||
|
@inject IAntiforgery antiforgery
|
||||||
|
@{
|
||||||
|
var token = antiforgery.GetAndStoreTokens(httpContextAccessor.HttpContext).RequestToken;
|
||||||
|
}
|
||||||
|
<input type="hidden" value="@token" name="__RequestVerificationToken" id="__RequestVerificationToken" />
|
@ -43,7 +43,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
@RenderBody()
|
@RenderBody()
|
||||||
|
<partial name="_AntiForgeryPartial.cshtml" />
|
||||||
<footer class="text-center">
|
<footer class="text-center">
|
||||||
<div class="container-fluid text-muted py-4 py-lg-5">
|
<div class="container-fluid text-muted py-4 py-lg-5">
|
||||||
<ul class="list-inline">
|
<ul class="list-inline">
|
||||||
|
@ -10,6 +10,7 @@ const bundles = {
|
|||||||
outputFileName: "wwwroot/dist/js/jfa.js",
|
outputFileName: "wwwroot/dist/js/jfa.js",
|
||||||
inputFiles: [
|
inputFiles: [
|
||||||
"Assets/js/_Jfa.js",
|
"Assets/js/_Jfa.js",
|
||||||
|
"Assets/js/Page/_Page.js",
|
||||||
"Assets/js/Utilities/Routing/_Routing.js",
|
"Assets/js/Utilities/Routing/_Routing.js",
|
||||||
"Assets/js/Utilities/Element/_Element.js",
|
"Assets/js/Utilities/Element/_Element.js",
|
||||||
"Assets/js/Utilities/Request/_Request.js",
|
"Assets/js/Utilities/Request/_Request.js",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user