user authentication
This commit is contained in:
@@ -93,7 +93,7 @@ console.log('Hello, World!');
|
||||
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}}";
|
||||
|
||||
@@ -174,8 +174,12 @@ console.log('Hello, World!');
|
||||
formData.append('content', content);
|
||||
formData.append('folder_path', folderPath);
|
||||
|
||||
fetch('/create', {
|
||||
// CSRF token from cookie
|
||||
const csrf = (document.cookie.match(/(?:^|; )csrf_token=([^;]+)/)||[])[1] ? decodeURIComponent((document.cookie.match(/(?:^|; )csrf_token=([^;]+)/)||[])[1]) : '';
|
||||
|
||||
fetch('/editor/create', {
|
||||
method: 'POST',
|
||||
headers: csrf ? { 'X-CSRF-Token': csrf } : {},
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
|
||||
Reference in New Issue
Block a user