mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-25 15:47:55 +01:00
Add CSRF to load
This commit is contained in:
parent
c95b5c5a50
commit
9650d27490
@ -43,7 +43,7 @@ class LocalStorageManager extends PersistenceManager {
|
|||||||
if (xml == null || this.forceLoad) {
|
if (xml == null || this.forceLoad) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: this.documentUrl.replace('{id}', mapId),
|
url: this.documentUrl.replace('{id}', mapId),
|
||||||
headers: { 'Content-Type': 'text/plain', Accept: 'application/xml' },
|
headers: { 'Content-Type': 'text/plain', Accept: 'application/xml', 'X-CSRF-Token': this.getCSRFToken() },
|
||||||
type: 'get',
|
type: 'get',
|
||||||
dataType: 'text',
|
dataType: 'text',
|
||||||
async: false,
|
async: false,
|
||||||
|
@ -52,6 +52,10 @@ abstract class PersistenceManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected getCSRFToken(): string {
|
||||||
|
return document.head.querySelector('meta[name="_csrf"]').getAttribute('content');
|
||||||
|
}
|
||||||
|
|
||||||
load(mapId: string) {
|
load(mapId: string) {
|
||||||
$assert(mapId, 'mapId can not be null');
|
$assert(mapId, 'mapId can not be null');
|
||||||
const domDocument = this.loadMapDom(mapId);
|
const domDocument = this.loadMapDom(mapId);
|
||||||
|
@ -159,10 +159,6 @@ class RESTPersistenceManager extends PersistenceManager {
|
|||||||
return { severity, message };
|
return { severity, message };
|
||||||
}
|
}
|
||||||
|
|
||||||
private getCSRFToken(): string {
|
|
||||||
return document.head.querySelector('meta[name="_csrf"]').getAttribute('content');
|
|
||||||
}
|
|
||||||
|
|
||||||
loadMapDom(mapId: string): Document {
|
loadMapDom(mapId: string): Document {
|
||||||
let xml: Document;
|
let xml: Document;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
Loading…
Reference in New Issue
Block a user