user authentication
This commit is contained in:
@@ -84,7 +84,7 @@
|
||||
const editorGrid = document.getElementById('editor-grid');
|
||||
const togglePreviewBtn = document.getElementById('toggle-preview');
|
||||
|
||||
const imageStorageMode = {{.image_storage_mode}};
|
||||
const imageStorageMode = parseInt('{{.image_storage_mode}}', 10) || 1;
|
||||
const imageSubfolderName = "{{.image_subfolder_name}}";
|
||||
const currentFolderPath = "{{.folder_path}}";
|
||||
const currentNotePath = "{{.note_path}}";
|
||||
@@ -158,8 +158,12 @@
|
||||
const formData = new FormData();
|
||||
formData.append('content', content);
|
||||
|
||||
fetch('/edit/' + notePath, {
|
||||
// CSRF token from cookie
|
||||
const csrf = (document.cookie.match(/(?:^|; )csrf_token=([^;]+)/)||[])[1] ? decodeURIComponent((document.cookie.match(/(?:^|; )csrf_token=([^;]+)/)||[])[1]) : '';
|
||||
|
||||
fetch('/editor/edit/' + notePath, {
|
||||
method: 'POST',
|
||||
headers: csrf ? { 'X-CSRF-Token': csrf } : {},
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
|
||||
Reference in New Issue
Block a user