Skip to content

Commit

Permalink
Исправил баг с csrf при экспорте заметки в zip
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikMix committed May 19, 2024
1 parent 7c178ba commit 57ed72f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions public/src/modules/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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')
};
}

Expand Down
2 changes: 2 additions & 0 deletions public/src/modules/stores/NotesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,8 @@ class NotesStore extends BaseStore<NotesStoreState> {
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")
Expand Down

0 comments on commit 57ed72f

Please sign in to comment.