mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-25 07: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) {
|
||||
$.ajax({
|
||||
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',
|
||||
dataType: 'text',
|
||||
async: false,
|
||||
|
@ -52,6 +52,10 @@ abstract class PersistenceManager {
|
||||
}
|
||||
}
|
||||
|
||||
protected getCSRFToken(): string {
|
||||
return document.head.querySelector('meta[name="_csrf"]').getAttribute('content');
|
||||
}
|
||||
|
||||
load(mapId: string) {
|
||||
$assert(mapId, 'mapId can not be null');
|
||||
const domDocument = this.loadMapDom(mapId);
|
||||
|
@ -159,10 +159,6 @@ class RESTPersistenceManager extends PersistenceManager {
|
||||
return { severity, message };
|
||||
}
|
||||
|
||||
private getCSRFToken(): string {
|
||||
return document.head.querySelector('meta[name="_csrf"]').getAttribute('content');
|
||||
}
|
||||
|
||||
loadMapDom(mapId: string): Document {
|
||||
let xml: Document;
|
||||
$.ajax({
|
||||
|
Loading…
Reference in New Issue
Block a user