From 3fb51f7c72affd7a9d2438caa6f9be926f98a561 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 12 Jul 2024 12:51:25 -0400 Subject: [PATCH 1/6] set csrf cookie before language client retry connection --- resources/js/components/EditorPanel.js | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/js/components/EditorPanel.js b/resources/js/components/EditorPanel.js index 5c88e8e..afd86e8 100644 --- a/resources/js/components/EditorPanel.js +++ b/resources/js/components/EditorPanel.js @@ -132,6 +132,7 @@ export default class EditorPanel try { + await axios.get('/sanctum/csrf-cookie'); await this.monacoWrapper.getLanguageClientWrapper().start(); } catch(e) From 33e2c562835cc8f6e6640791693e1006c5408ef6 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 12 Jul 2024 12:51:51 -0400 Subject: [PATCH 2/6] set csrf cookie before starting monaco editor --- resources/js/lib/monacoWrapper.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/js/lib/monacoWrapper.js b/resources/js/lib/monacoWrapper.js index 23d7fff..64bb7cc 100644 --- a/resources/js/lib/monacoWrapper.js +++ b/resources/js/lib/monacoWrapper.js @@ -34,12 +34,16 @@ export const runCppWrapper = async() => const userConfig = createUserConfig('/workspace', "", '/workspace/pgetinker.cpp'); const wrapper = new MonacoEditorLanguageClientWrapper(); - try { + try + { + await axios.get('/sanctum/csrf-cookie'); await wrapper.init(userConfig); // open files, so the LS can pick it up await vscode.workspace.openTextDocument(pgetinkerCppUri); - } catch (e) { + } + catch (e) + { console.error(e); } From 2a4f51a3c59b5f6a7bfe5bf5d878bfa837ad973f Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 12 Jul 2024 12:53:15 -0400 Subject: [PATCH 3/6] set csrf cookie before calling /api/compile and /api/share --- resources/js/app.ts | 118 ++++++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 53 deletions(-) diff --git a/resources/js/app.ts b/resources/js/app.ts index c9caecb..c268470 100644 --- a/resources/js/app.ts +++ b/resources/js/app.ts @@ -226,45 +226,50 @@ export default class PGEtinker if(!this.preCompile()) return; - axios.post("/api/share", { - code: this.editorPanel.getValue() - }).then((response) => - { - this.compileSuccessHandler(response.data); + axios.get('/sanctum/csrf-cookie').then(_ => { + axios.post("/api/share", { + code: this.editorPanel.getValue() + }).then((response) => + { + this.compileSuccessHandler(response.data); + + shareDialog(response.data.shareURL, response.data.shareThumbURL) + .finally(() => + { + + }); - shareDialog(response.data.shareURL, response.data.shareThumbURL) - .finally(() => - { - - }); + }).catch((error) => + { + this.setActiveTab("editor"); + playIconElem.classList.toggle("hidden", false); + stopIconElem.classList.toggle("hidden", true); + spanElem.innerHTML = "Run"; - }).catch((error) => - { - this.setActiveTab("editor"); - playIconElem.classList.toggle("hidden", false); - stopIconElem.classList.toggle("hidden", true); - spanElem.innerHTML = "Run"; - - if(error.response) - { - if(error.response.status) + if(error.response) { - if(error.response.status == 503) + if(error.response.status) { - this.compileFailHandler("pgetinker.cpp:1:1: error: PGEtinker service has gone offline. try again later.\n"); + if(error.response.status == 503) + { + this.compileFailHandler("pgetinker.cpp:1:1: error: PGEtinker service has gone offline. try again later.\n"); + return; + } + } + + if(error.response.data.stderr) + { + this.compileFailHandler(error.response.data.stderr); return; } } - - if(error.response.data.stderr) - { - this.compileFailHandler(error.response.data.stderr); - return; - } - } - - this.compileFailHandler("pgetinker.cpp:1:1: error: compilation failed in a way that's not being handled. please make a bug report.\n"); + + this.compileFailHandler("pgetinker.cpp:1:1: error: compilation failed in a way that's not being handled. please make a bug report.\n"); + }); + }).catch(() => + { + this.compileFailHandler("pgetinker.cpp:1:1: error: calling the compiler api failed.\n"); }); } @@ -313,37 +318,44 @@ export default class PGEtinker return new Promise((resolve, reject) => { - axios.post("/api/compile", { - code: this.editorPanel.getValue() - }).then((response) => - { - this.compileSuccessHandler(response.data); - resolve(); - }).catch((error) => - { - - if(error.response) + axios.get('/sanctum/csrf-cookie').then(_ => { + axios.post("/api/compile", { + code: this.editorPanel.getValue() + }).then((response) => { - if(error.response.status) + this.compileSuccessHandler(response.data); + resolve(); + }).catch((error) => + { + + if(error.response) { - if(error.response.status == 503) + if(error.response.status) { - this.compileFailHandler("pgetinker.cpp:1:1: error: PGEtinker service has gone offline. try again later.\n"); + if(error.response.status == 503) + { + this.compileFailHandler("pgetinker.cpp:1:1: error: PGEtinker service has gone offline. try again later.\n"); + reject(); + return; + } + } + + if(error.response.data.stderr) + { + this.compileFailHandler(error.response.data.stderr); reject(); return; } } - - if(error.response.data.stderr) - { - this.compileFailHandler(error.response.data.stderr); - reject(); - return; - } - } - this.compileFailHandler("pgetinker.cpp:1:1: error: compilation failed in a way that's not being handled. please make a bug report.\n"); + this.compileFailHandler("pgetinker.cpp:1:1: error: compilation failed in a way that's not being handled. please make a bug report.\n"); + reject(); + }); + }).catch(() => + { + this.compileFailHandler("pgetinker.cpp:1:1: error: calling the compiler api failed.\n"); reject(); }); + }); } From 1d916e66a2d1062d4024d6689301067242fdb356 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 12 Jul 2024 12:53:30 -0400 Subject: [PATCH 4/6] set csrf cookie before calling /api/supporters --- resources/js/lib/supportersDialog.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/resources/js/lib/supportersDialog.js b/resources/js/lib/supportersDialog.js index a01927c..720afb3 100644 --- a/resources/js/lib/supportersDialog.js +++ b/resources/js/lib/supportersDialog.js @@ -55,12 +55,15 @@ export default function supportersDialog() return new Promise((resolve) => { - axios.get("/api/supporters").then((response) => + axios.get('/sanctum/csrf-cookie').then(_ => { - renderSupportersDialog(response.data.supporters).then(() => resolve()); - }).catch((reason) => - { - renderSupportersDialog(reason.response.data.supporters).then(() => resolve()); + axios.get("/api/supporters").then((response) => + { + renderSupportersDialog(response.data.supporters).then(() => resolve()); + }).catch((reason) => + { + renderSupportersDialog(reason.response.data.supporters).then(() => resolve()); + }); }); }); } From 2796394ee3d3440adf9487acf52a782bf48b6442 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 12 Jul 2024 12:53:41 -0400 Subject: [PATCH 5/6] set csrf cookie before calling /api/news --- resources/js/lib/newsDialog.js | 75 ++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/resources/js/lib/newsDialog.js b/resources/js/lib/newsDialog.js index d736def..4819d31 100644 --- a/resources/js/lib/newsDialog.js +++ b/resources/js/lib/newsDialog.js @@ -8,45 +8,48 @@ export default function newsDialog() dialog.classList.toggle("dialog", true); dialog.classList.toggle("news", true); - axios.get("/api/news").then((response) => + axios.get('/sanctum/csrf-cookie').then(_ => { - - let entries = []; - - response.data.entries.forEach((entry) => + axios.get("/api/news").then((response) => { - entries.push(`
${entry.message}
`); - }); - - dialog.innerHTML = ` -
-
News and Updates
-
-

PGEtinker has been updated. Here's what's been done:

-

${response.data.date}

-
${entries.join("")}
- -

- For more details visit the PGEtinker github repository. -

-

- Version: ${version.substring(0, 7)} -

-
- -
`; - - dialog.querySelector("button.ok").addEventListener("click", (event) => - { - dialog.remove(); - resolve(); + + let entries = []; + + response.data.entries.forEach((entry) => + { + entries.push(`
${entry.message}
`); + }); + + dialog.innerHTML = ` +
+
News and Updates
+
+

PGEtinker has been updated. Here's what's been done:

+

${response.data.date}

+
${entries.join("")}
+ +

+ For more details visit the PGEtinker github repository. +

+

+ Version: ${version.substring(0, 7)} +

+
+ +
`; + + dialog.querySelector("button.ok").addEventListener("click", (event) => + { + dialog.remove(); + resolve(); + }); + + document.body.appendChild(dialog); }); - - document.body.appendChild(dialog); - }); - + }); + }); } \ No newline at end of file From 6b490b3a0577a3feb5b0f28e6dbb800891c9b50d Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 12 Jul 2024 12:55:03 -0400 Subject: [PATCH 6/6] update changelog --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b22cf08..f5ef185 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,12 @@ All notable changes to this project will be documented in this file. Each batch It is a summary of changes that would be pertinent to the end user of the PGEtinker website. For a comprehensive history of changes made to the project, please refer to the repository's commit history. -## 20204-07-07 +## 2024-07-12 + +- Fixed [Issue #120](https://github.com/Moros1138/PGEtinker/issues/120) + + +## 2024-07-07 - Fixed bug involving shared code persistence - Changed threshold for responsive navbar