convert csrfToken to get method

This commit is contained in:
tekh 2025-09-09 18:11:14 +02:00
parent 1ac2a476d2
commit 207bc8bcbd
4 changed files with 16 additions and 4 deletions

View File

@ -82,4 +82,14 @@ public class DocumentReceiverElementDto
/// Gets or sets the timestamp when the element was last changed, if applicable.
/// </summary>
public DateTime? ChangedWhen { get; set; }
/// <summary>
/// Gets or sets the top position of the element (in layout terms).
/// </summary>
public double Top => Y;
/// <summary>
/// Gets or sets the left position of the element (in layout terms).
/// </summary>
public double Left => X;
}

View File

@ -3,7 +3,7 @@ async function createAnnotations(document, instance) {
const signatures = [];
for(var element of document.elements) {
const annotParams = await getAnnotationParams(element.x, element.y);
const annotParams = await getAnnotationParams(element.left, element.top);
const page = element.page - 1
//background

View File

@ -1,7 +1,9 @@
/**
* Fetches CSRF Token from page
*/
const csrfToken = { 'X-XSRF-TOKEN': document.getElementsByName('__RequestVerificationToken')[0].value };
function getCsrfToken() {
return { 'X-XSRF-TOKEN': document.getElementsByName('__RequestVerificationToken')[0].value }
}
/**
* Save signature data to server
@ -9,7 +11,7 @@ const csrfToken = { 'X-XSRF-TOKEN': document.getElementsByName('__RequestVerific
* @param {any} annotations
*/
function postEnvelope(annotations) {
const token = csrfToken
const token = getCsrfToken()
const options = {
credentials: 'include',
method: 'POST',

View File

@ -1 +1 @@
function postEnvelope(n){const t=csrfToken,i={credentials:"include",method:"POST",headers:{...t,"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(n)};return fetch(`/api/envelope`,i)}async function setLangAsync(n,t){document.getElementById("selectedFlag").className="fi "+t+" me-2";await fetch(`/api/localization/lang/${n}`,{method:"POST",headers:{"Content-Type":"application/json"}})}async function setLanguage(n){const t=await fetch("/api/localization/lang",{method:"GET",headers:{"Content-Type":"application/json"}}).then(n=>n.json()).then(t=>t.includes(n)).catch(()=>!1);if(t)return await fetch(`/api/localization/lang/${n}`,{method:"POST",headers:{"Content-Type":"application/json"}}).then(n=>{if(n.redirected)window.location.href=n.url;else if(!n.ok)return Promise.reject("Failed to set language")})}async function logout(){return await fetch(`/auth/logout`,{method:"POST",headers:{"Content-Type":"application/json"}}).then(n=>{n.ok&&(window.location.href="/")})}async function getAnnotationParams(n=0,t=0,i=72){var f,r;const u=await fetch(`${window.location.origin}/api/Config/Annotations`,{credentials:"include",method:"GET"}).then(n=>n.json());for(f in u)r=u[f],r.width*=i,r.height*=i,r.left+=n-.7,r.left*=i,r.top+=t-.5,r.top*=i;return u}const csrfToken={"X-XSRF-TOKEN":document.getElementsByName("__RequestVerificationToken")[0].value};
function getCsrfToken(){return{"X-XSRF-TOKEN":document.getElementsByName("__RequestVerificationToken")[0].value}}function postEnvelope(n){const t=getCsrfToken(),i={credentials:"include",method:"POST",headers:{...t,"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(n)};return fetch(`/api/envelope`,i)}async function setLangAsync(n,t){document.getElementById("selectedFlag").className="fi "+t+" me-2";await fetch(`/api/localization/lang/${n}`,{method:"POST",headers:{"Content-Type":"application/json"}})}async function setLanguage(n){const t=await fetch("/api/localization/lang",{method:"GET",headers:{"Content-Type":"application/json"}}).then(n=>n.json()).then(t=>t.includes(n)).catch(()=>!1);if(t)return await fetch(`/api/localization/lang/${n}`,{method:"POST",headers:{"Content-Type":"application/json"}}).then(n=>{if(n.redirected)window.location.href=n.url;else if(!n.ok)return Promise.reject("Failed to set language")})}async function logout(){return await fetch(`/auth/logout`,{method:"POST",headers:{"Content-Type":"application/json"}}).then(n=>{n.ok&&(window.location.href="/")})}async function getAnnotationParams(n=0,t=0,i=72){var f,r;const u=await fetch(`${window.location.origin}/api/Config/Annotations`,{credentials:"include",method:"GET"}).then(n=>n.json());for(f in u)r=u[f],r.width*=i,r.height*=i,r.left+=n-.7,r.left*=i,r.top+=t-.5,r.top*=i;return u}