From 24c8e296910a9f4df5794f819541bde5ac76ba8d Mon Sep 17 00:00:00 2001 From: Geometrically <18202329+Geometrically@users.noreply.github.com> Date: Mon, 29 Mar 2021 09:43:00 -0700 Subject: [PATCH] More secure custom authentication solution (#126) * Remove Nuxt Auth from the project, and switch to a custom solution * Replace old testing code * Remove warnings * Add comments to hard to understand function calls in middleware * Use arrow functions --- components/ModPage.vue | 22 +- layouts/default.vue | 23 +- middleware/auth.js | 63 ++++ nuxt.config.js | 21 +- package-lock.json | 355 ++++------------------- package.json | 3 +- pages/dashboard/misc/revoke-token.vue | 2 +- pages/dashboard/moderation.vue | 38 +-- pages/dashboard/notifications.vue | 24 +- pages/dashboard/projects.vue | 12 +- pages/dashboard/settings.vue | 24 +- pages/mod/_id/edit.vue | 20 +- pages/mod/_id/index.vue | 18 +- pages/mod/_id/newversion.vue | 20 +- pages/mod/_id/settings.vue | 52 +--- pages/mod/_id/version/_version/edit.vue | 28 +- pages/mod/_id/version/_version/index.vue | 46 +-- pages/mod/_id/versions.vue | 18 +- pages/mod/create.vue | 2 +- pages/report/create.vue | 14 +- pages/user/_id.vue | 24 +- plugins/auth.js | 3 + store/auth.js | 53 ++++ 23 files changed, 271 insertions(+), 614 deletions(-) create mode 100644 middleware/auth.js create mode 100644 plugins/auth.js create mode 100644 store/auth.js diff --git a/components/ModPage.vue b/components/ModPage.vue index b0957659..9cef4223 100644 --- a/components/ModPage.vue +++ b/components/ModPage.vue @@ -38,7 +38,7 @@
@@ -458,34 +458,18 @@ export default { elem.click() }, async followMod() { - const config = { - headers: { - Authorization: this.$auth.getToken('local') - ? this.$auth.getToken('local') - : '', - }, - } - await axios.post( `https://api.modrinth.com/api/v1/mod/${this.mod.id}/follow`, {}, - config + this.$auth.headers ) this.userFollows.push(this.mod.id) }, async unfollowMod() { - const config = { - headers: { - Authorization: this.$auth.getToken('local') - ? this.$auth.getToken('local') - : '', - }, - } - await axios.delete( `https://api.modrinth.com/api/v1/mod/${this.mod.id}/follow`, - config + this.$auth.headers ) this.userFollows.splice(this.userFollows.indexOf(this.mod.id), 1) diff --git a/layouts/default.vue b/layouts/default.vue index cef2afbb..e72ef2ed 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -18,7 +18,7 @@ Mods -
+
Dashboard @@ -28,7 +28,7 @@
-