From 57ed72ff49356f69bc420104efb013eceedc2e5a Mon Sep 17 00:00:00 2001 From: YarikMix <43493788+YarikMix@users.noreply.github.com> Date: Mon, 20 May 2024 01:22:42 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B1=D0=B0=D0=B3=20=D1=81=20csrf=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D1=8D=D0=BA=D1=81=D0=BF=D0=BE=D1=80=D1=82=D0=B5=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BC=D0=B5=D1=82=D0=BA=D0=B8=20=D0=B2=20zip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/src/modules/api.ts | 7 ++++--- public/src/modules/stores/NotesStore.ts | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/public/src/modules/api.ts b/public/src/modules/api.ts index b9b28837..ecafd3ac 100644 --- a/public/src/modules/api.ts +++ b/public/src/modules/api.ts @@ -564,8 +564,6 @@ class NoteRequests { } ExportToZip = async (note_id:string, note: string, jwt:string, csrf:string) => { - console.log("ExportToZip") - const options: RequestInit = { method: RequestMethods.POST, body: note, @@ -579,12 +577,15 @@ class NoteRequests { const response = await fetch(baseUrl + "/note/" + note_id + "/make_zip", options); + console.log(response.headers['x-csrf-token']) + console.log(response) + if (response.status == 200) { const blob = await response.blob() return { url: URL.createObjectURL(blob), status: response.status, - csrf: response.headers['x-csrf-token'] + csrf: response.headers.get('x-csrf-token') }; } diff --git a/public/src/modules/stores/NotesStore.ts b/public/src/modules/stores/NotesStore.ts index 9216616e..c9360500 100644 --- a/public/src/modules/stores/NotesStore.ts +++ b/public/src/modules/stores/NotesStore.ts @@ -767,6 +767,8 @@ class NotesStore extends BaseStore { const note = document.querySelector(".note-editor-content").outerHTML const {url, csrf} = await AppNoteRequests.ExportToZip(this.state.selectedNote.id, note, AppUserStore.state.JWT, AppUserStore.state.csrf) + console.log(csrf) + AppDispatcher.dispatch(UserActions.UPDATE_CSRF, csrf); downloadFile(url, parseNoteTitle(AppNoteStore.state.note.title) + ".zip")