diff --git a/middleware/auth.js b/middleware/auth.js
new file mode 100644
index 000000000..2073d222d
--- /dev/null
+++ b/middleware/auth.js
@@ -0,0 +1,63 @@
+export default async function (context) {
+ if (!context.from) {
+ if (context.route.query.code) {
+ context.app.$cookies.set('auth-token', context.route.query.code, {
+ secure: true,
+ sameSite: 'Strict',
+ httpOnly: true,
+ })
+
+ return context.redirect(context.route.path)
+ }
+
+ if (context.app.$cookies.get('auth-token')) {
+ const cookie = context.app.$cookies.get('auth-token')
+
+ await context.store.dispatch('auth/fetchUser', { token: cookie })
+ }
+ }
+
+ // Disable middleware if options: { auth: false } is set on the route
+ if (routeOption(context.route, 'auth', false)) return
+
+ // Disable middleware if no route was matched to allow 404/error page
+ if (!getMatchedComponents(context.route, []).length) {
+ return
+ }
+
+ if (!context.$auth.user) {
+ return context.redirect(
+ `https://api.modrinth.com/api/v1/auth/init?url=https://modrinth.com${context.route.fullPath}`
+ )
+ }
+}
+
+function routeOption(route, key, value) {
+ return route.matched.some((m) => {
+ if (process.client) {
+ // Client
+ return Object.values(m.components).some(
+ (component) => component.options && component.options[key] === value
+ )
+ } else {
+ // SSR
+ return Object.values(m.components).some((component) =>
+ Object.values(component._Ctor).some(
+ (ctor) => ctor.options && ctor.options[key] === value
+ )
+ )
+ }
+ })
+}
+
+function getMatchedComponents(route, matches) {
+ return [].concat(
+ ...[],
+ ...route.matched.map((m, index) => {
+ return Object.keys(m.components).map((key) => {
+ matches.push(index)
+ return m.components[key]
+ })
+ })
+ )
+}
diff --git a/nuxt.config.js b/nuxt.config.js
index ee2aba778..6c71c606c 100644
--- a/nuxt.config.js
+++ b/nuxt.config.js
@@ -77,9 +77,8 @@ export default {
devtools: true,
},
},
-
router: {
- middleware: ['auth'],
+ middleware: 'auth',
},
/*
** Global CSS
@@ -94,6 +93,7 @@ export default {
'~/plugins/vue-notification.js',
'~/plugins/compiled-markdown-directive.js',
'~/plugins/vue-syntax.js',
+ '~/plugins/auth.js',
],
/*
** Auto import components
@@ -116,12 +116,11 @@ export default {
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/dayjs',
'@nuxtjs/axios',
- '@nuxtjs/auth',
'@nuxtjs/robots',
'@nuxtjs/sitemap',
- 'nuxt-clipboard2',
'@nuxtjs/style-resources',
'@nuxtjs/google-adsense',
+ 'cookie-universal-nuxt',
],
robots: {
Sitemap: 'https://modrinth.com/sitemap.xml',
@@ -129,20 +128,6 @@ export default {
sitemap: {
exclude: ['/dashboard/**', '/dashboard', '/mod/create'],
},
- auth: {
- strategies: {
- local: {
- endpoints: {
- user: {
- url: 'https://api.modrinth.com/api/v1/user',
- method: 'get',
- propertyName: false,
- },
- },
- tokenType: false,
- },
- },
- },
/*
** Axios module configuration
** See https://axios.nuxtjs.org/options
diff --git a/package-lock.json b/package-lock.json
index 0c6641b2d..35bd2d1cd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,17 +8,16 @@
"name": "knossos",
"version": "1.0.0",
"dependencies": {
- "@nuxtjs/auth": "^4.9.1",
"@nuxtjs/axios": "^5.12.5",
"@nuxtjs/dayjs": "^1.2.0",
"@nuxtjs/google-adsense": "^1.3.0",
"@nuxtjs/robots": "^2.4.2",
"@nuxtjs/sitemap": "^2.4.0",
"@nuxtjs/style-resources": "^1.0.0",
+ "cookie-universal-nuxt": "^2.1.4",
"highlight.js": "^10.3.2",
"marked": "^2.0.0",
"nuxt": "^2.14.7",
- "nuxt-clipboard2": "^0.2.1",
"v-tooltip": "^2.0.3",
"vue-click-outside": "^1.1.0",
"vue-highlightjs": "^1.3.3",
@@ -1630,11 +1629,6 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
- "node_modules/@nuxt/builder/node_modules/consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"node_modules/@nuxt/builder/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -1739,11 +1733,6 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
- "node_modules/@nuxt/cli/node_modules/consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"node_modules/@nuxt/cli/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -1793,11 +1782,6 @@
"std-env": "^2.2.1"
}
},
- "node_modules/@nuxt/config/node_modules/consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"node_modules/@nuxt/config/node_modules/defu": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/defu/-/defu-2.0.4.tgz",
@@ -1822,11 +1806,6 @@
"std-env": "^2.2.1"
}
},
- "node_modules/@nuxt/core/node_modules/consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"node_modules/@nuxt/core/node_modules/debug": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
@@ -1931,11 +1910,6 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
- "node_modules/@nuxt/generator/node_modules/consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"node_modules/@nuxt/generator/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -1989,11 +1963,6 @@
"npm": ">=5.0.0"
}
},
- "node_modules/@nuxt/opencollective/node_modules/consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"node_modules/@nuxt/server": {
"version": "2.14.7",
"resolved": "https://registry.npmjs.org/@nuxt/server/-/server-2.14.7.tgz",
@@ -2058,11 +2027,6 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
- "node_modules/@nuxt/server/node_modules/consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"node_modules/@nuxt/server/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -2157,11 +2121,6 @@
"ua-parser-js": "^0.7.22"
}
},
- "node_modules/@nuxt/utils/node_modules/consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"node_modules/@nuxt/vue-app": {
"version": "2.14.7",
"resolved": "https://registry.npmjs.org/@nuxt/vue-app/-/vue-app-2.14.7.tgz",
@@ -2193,11 +2152,6 @@
"vue-server-renderer": "^2.6.12"
}
},
- "node_modules/@nuxt/vue-renderer/node_modules/consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"node_modules/@nuxt/webpack": {
"version": "2.14.7",
"resolved": "https://registry.npmjs.org/@nuxt/webpack/-/webpack-2.14.7.tgz",
@@ -2289,11 +2243,6 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
- "node_modules/@nuxt/webpack/node_modules/consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"node_modules/@nuxt/webpack/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -2321,43 +2270,18 @@
"node": ">=8"
}
},
- "node_modules/@nuxtjs/auth": {
- "version": "4.9.1",
- "resolved": "https://registry.npmjs.org/@nuxtjs/auth/-/auth-4.9.1.tgz",
- "integrity": "sha512-h5VZanq2+P47jq3t0EnsZv800cg/ufOPC6JqvcyeDFJM99p58jHSODAjDuePo3PrZxd8hovMk7zusU5lOHgjvQ==",
- "dependencies": {
- "@nuxtjs/axios": "^5.9.5",
- "body-parser": "^1.19.0",
- "consola": "^2.11.3",
- "cookie": "^0.4.0",
- "is-https": "^1.0.0",
- "js-cookie": "^2.2.1",
- "lodash": "^4.17.15",
- "nanoid": "^2.1.11"
- }
- },
- "node_modules/@nuxtjs/auth/node_modules/nanoid": {
- "version": "2.1.11",
- "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.11.tgz",
- "integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA=="
- },
"node_modules/@nuxtjs/axios": {
- "version": "5.12.5",
- "resolved": "https://registry.npmjs.org/@nuxtjs/axios/-/axios-5.12.5.tgz",
- "integrity": "sha512-KCZMLRZFYOKcGt9mKxJMH6UJMB6H6g+BF/YxXEYz3Urrf2U2XiNkj6rmBqgw0XLRY5XD9Wm8knTGp6955512fQ==",
+ "version": "5.13.1",
+ "resolved": "https://registry.npmjs.org/@nuxtjs/axios/-/axios-5.13.1.tgz",
+ "integrity": "sha512-vZpXV2AAkQ5Duejubt1k3ZgUnYowYnPvmcUt0hskd+OebmQ+jF6Wk6rOG0/9EeknOxm7mtTGgKSwdlE1jDo+xA==",
"dependencies": {
"@nuxtjs/proxy": "^2.1.0",
"axios": "^0.21.1",
"axios-retry": "^3.1.9",
- "consola": "^2.15.0",
+ "consola": "^2.15.3",
"defu": "^3.2.2"
}
},
- "node_modules/@nuxtjs/axios/node_modules/consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"node_modules/@nuxtjs/color-mode": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@nuxtjs/color-mode/-/color-mode-1.1.1.tgz",
@@ -2580,6 +2504,11 @@
"resolved": "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz",
"integrity": "sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA=="
},
+ "node_modules/@types/cookie": {
+ "version": "0.3.3",
+ "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.3.3.tgz",
+ "integrity": "sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow=="
+ },
"node_modules/@types/html-minifier-terser": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz",
@@ -4528,16 +4457,6 @@
"node": ">= 10"
}
},
- "node_modules/clipboard": {
- "version": "2.0.6",
- "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.6.tgz",
- "integrity": "sha512-g5zbiixBRk/wyKakSwCKd7vQXDjFnAMGHoEyBogG/bw9kTD9GvdAvaoRR1ALcEzt3pVKxZR0pViekPMIS0QyGg==",
- "dependencies": {
- "good-listener": "^1.2.2",
- "select": "^1.1.2",
- "tiny-emitter": "^2.0.0"
- }
- },
"node_modules/cliui": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz",
@@ -4819,9 +4738,9 @@
}
},
"node_modules/consola": {
- "version": "2.14.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.14.0.tgz",
- "integrity": "sha512-A2j1x4u8d6SIVikhZROfpFJxQZie+cZOfQMyI/tu2+hWXe8iAv7R6FW6s6x04/7zBCst94lPddztot/d6GJiuQ=="
+ "version": "2.15.3",
+ "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz",
+ "integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw=="
},
"node_modules/console-browserify": {
"version": "1.2.0",
@@ -4909,6 +4828,24 @@
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
},
+ "node_modules/cookie-universal": {
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/cookie-universal/-/cookie-universal-2.1.4.tgz",
+ "integrity": "sha512-dwWXs7NGBzaBYDypu3jWH5M3NJW+zu5QdyJkFMHJvhLuyL4/eXG4105fwtTDwfIqyTunwVvQX4PHdtfPDS7URQ==",
+ "dependencies": {
+ "@types/cookie": "^0.3.3",
+ "cookie": "^0.4.0"
+ }
+ },
+ "node_modules/cookie-universal-nuxt": {
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/cookie-universal-nuxt/-/cookie-universal-nuxt-2.1.4.tgz",
+ "integrity": "sha512-xbn4Ozs9S0u2+0mQTZRwGlBL9MGNq8N4H6iGfprR5ufZFCS2hGef++3DBHSmHXZi30Wu3Q7RI/GkNMhz3cecmg==",
+ "dependencies": {
+ "@types/cookie": "^0.3.3",
+ "cookie-universal": "^2.1.4"
+ }
+ },
"node_modules/copy-concurrently": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz",
@@ -5560,11 +5497,6 @@
"node": ">=0.4.0"
}
},
- "node_modules/delegate": {
- "version": "3.2.0",
- "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz",
- "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw=="
- },
"node_modules/delegates": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz",
@@ -7939,14 +7871,6 @@
"node": ">= 0.10"
}
},
- "node_modules/good-listener": {
- "version": "1.2.2",
- "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz",
- "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=",
- "dependencies": {
- "delegate": "^3.1.2"
- }
- },
"node_modules/graceful-fs": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
@@ -8910,11 +8834,6 @@
"node": ">=0.10.0"
}
},
- "node_modules/is-https": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/is-https/-/is-https-1.0.0.tgz",
- "integrity": "sha512-1adLLwZT9XEXjzhQhZxd75uxf0l+xI9uTSFaZeSESjL3E1eXSPpO+u5RcgqtzeZ1KCaNvtEwZSTO2P4U5erVqQ=="
- },
"node_modules/is-nan": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.0.tgz",
@@ -9153,11 +9072,6 @@
"integrity": "sha512-fiUvdfCaAXoQTHdKMgTvg6IkecXDcVz6V5rlftUTclF9IKBjMizvSdQaCl/z/6TApDeby5NL+axYou3i0mu1Pg==",
"dev": true
},
- "node_modules/js-cookie": {
- "version": "2.2.1",
- "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-2.2.1.tgz",
- "integrity": "sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ=="
- },
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@@ -10568,14 +10482,6 @@
"npm": ">=5.0.0"
}
},
- "node_modules/nuxt-clipboard2": {
- "version": "0.2.1",
- "resolved": "https://registry.npmjs.org/nuxt-clipboard2/-/nuxt-clipboard2-0.2.1.tgz",
- "integrity": "sha512-NZl9UpcLjePt3CRhYSmJiv7af5IiI1DRrmesGawapjImmWZ2cO+UqflimIlBqIXjJSnz3ZsaPxX4639UgkxYTA==",
- "dependencies": {
- "vue-clipboard2": "0.2.1"
- }
- },
"node_modules/oauth-sign": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
@@ -13450,11 +13356,6 @@
"node": ">=0.8.0"
}
},
- "node_modules/select": {
- "version": "1.1.2",
- "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz",
- "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0="
- },
"node_modules/semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
@@ -14656,11 +14557,6 @@
"resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz",
"integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q="
},
- "node_modules/tiny-emitter": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
- "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q=="
- },
"node_modules/tmp": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
@@ -15235,14 +15131,6 @@
"resolved": "https://registry.npmjs.org/vue-client-only/-/vue-client-only-2.0.0.tgz",
"integrity": "sha512-arhk1wtWAfLsJyxGMoEYhoBowM87/i6HLSG2LH/03Yog6i2d9JEN1peMP0Ceis+/n9DxdenGYZZTxbPPJyHciA=="
},
- "node_modules/vue-clipboard2": {
- "version": "0.2.1",
- "resolved": "https://registry.npmjs.org/vue-clipboard2/-/vue-clipboard2-0.2.1.tgz",
- "integrity": "sha512-n6ie/0g0bKohmLlC/5ja1esq2Q0jQ5hWmhNSZcvCsWfDeDnVARjl6cBB9p72XV1nlVfuqsZcfV8HTjjZAIlLBA==",
- "dependencies": {
- "clipboard": "^2.0.0"
- }
- },
"node_modules/vue-eslint-parser": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-7.1.0.tgz",
@@ -18144,11 +18032,6 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
- "consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -18234,11 +18117,6 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
- "consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -18284,11 +18162,6 @@
"std-env": "^2.2.1"
},
"dependencies": {
- "consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"defu": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/defu/-/defu-2.0.4.tgz",
@@ -18315,11 +18188,6 @@
"std-env": "^2.2.1"
},
"dependencies": {
- "consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"debug": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
@@ -18409,11 +18277,6 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
- "consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -18456,13 +18319,6 @@
"chalk": "^4.1.0",
"consola": "^2.15.0",
"node-fetch": "^2.6.1"
- },
- "dependencies": {
- "consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- }
}
},
"@nuxt/server": {
@@ -18520,11 +18376,6 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
- "consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -18608,13 +18459,6 @@
"serialize-javascript": "^5.0.1",
"signal-exit": "^3.0.3",
"ua-parser-js": "^0.7.22"
- },
- "dependencies": {
- "consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- }
}
},
"@nuxt/vue-app": {
@@ -18646,13 +18490,6 @@
"vue": "^2.6.12",
"vue-meta": "^2.4.0",
"vue-server-renderer": "^2.6.12"
- },
- "dependencies": {
- "consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- }
}
},
"@nuxt/webpack": {
@@ -18734,11 +18571,6 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
- "consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- },
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -18759,45 +18591,16 @@
}
}
},
- "@nuxtjs/auth": {
- "version": "4.9.1",
- "resolved": "https://registry.npmjs.org/@nuxtjs/auth/-/auth-4.9.1.tgz",
- "integrity": "sha512-h5VZanq2+P47jq3t0EnsZv800cg/ufOPC6JqvcyeDFJM99p58jHSODAjDuePo3PrZxd8hovMk7zusU5lOHgjvQ==",
- "requires": {
- "@nuxtjs/axios": "^5.9.5",
- "body-parser": "^1.19.0",
- "consola": "^2.11.3",
- "cookie": "^0.4.0",
- "is-https": "^1.0.0",
- "js-cookie": "^2.2.1",
- "lodash": "^4.17.15",
- "nanoid": "^2.1.11"
- },
- "dependencies": {
- "nanoid": {
- "version": "2.1.11",
- "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.11.tgz",
- "integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA=="
- }
- }
- },
"@nuxtjs/axios": {
- "version": "5.12.5",
- "resolved": "https://registry.npmjs.org/@nuxtjs/axios/-/axios-5.12.5.tgz",
- "integrity": "sha512-KCZMLRZFYOKcGt9mKxJMH6UJMB6H6g+BF/YxXEYz3Urrf2U2XiNkj6rmBqgw0XLRY5XD9Wm8knTGp6955512fQ==",
+ "version": "5.13.1",
+ "resolved": "https://registry.npmjs.org/@nuxtjs/axios/-/axios-5.13.1.tgz",
+ "integrity": "sha512-vZpXV2AAkQ5Duejubt1k3ZgUnYowYnPvmcUt0hskd+OebmQ+jF6Wk6rOG0/9EeknOxm7mtTGgKSwdlE1jDo+xA==",
"requires": {
"@nuxtjs/proxy": "^2.1.0",
"axios": "^0.21.1",
"axios-retry": "^3.1.9",
- "consola": "^2.15.0",
+ "consola": "^2.15.3",
"defu": "^3.2.2"
- },
- "dependencies": {
- "consola": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
- "integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ=="
- }
}
},
"@nuxtjs/color-mode": {
@@ -19007,6 +18810,11 @@
"resolved": "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz",
"integrity": "sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA=="
},
+ "@types/cookie": {
+ "version": "0.3.3",
+ "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.3.3.tgz",
+ "integrity": "sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow=="
+ },
"@types/html-minifier-terser": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz",
@@ -20682,16 +20490,6 @@
"resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz",
"integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw=="
},
- "clipboard": {
- "version": "2.0.6",
- "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.6.tgz",
- "integrity": "sha512-g5zbiixBRk/wyKakSwCKd7vQXDjFnAMGHoEyBogG/bw9kTD9GvdAvaoRR1ALcEzt3pVKxZR0pViekPMIS0QyGg==",
- "requires": {
- "good-listener": "^1.2.2",
- "select": "^1.1.2",
- "tiny-emitter": "^2.0.0"
- }
- },
"cliui": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz",
@@ -20936,9 +20734,9 @@
}
},
"consola": {
- "version": "2.14.0",
- "resolved": "https://registry.npmjs.org/consola/-/consola-2.14.0.tgz",
- "integrity": "sha512-A2j1x4u8d6SIVikhZROfpFJxQZie+cZOfQMyI/tu2+hWXe8iAv7R6FW6s6x04/7zBCst94lPddztot/d6GJiuQ=="
+ "version": "2.15.3",
+ "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz",
+ "integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw=="
},
"console-browserify": {
"version": "1.2.0",
@@ -21015,6 +20813,24 @@
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
},
+ "cookie-universal": {
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/cookie-universal/-/cookie-universal-2.1.4.tgz",
+ "integrity": "sha512-dwWXs7NGBzaBYDypu3jWH5M3NJW+zu5QdyJkFMHJvhLuyL4/eXG4105fwtTDwfIqyTunwVvQX4PHdtfPDS7URQ==",
+ "requires": {
+ "@types/cookie": "^0.3.3",
+ "cookie": "^0.4.0"
+ }
+ },
+ "cookie-universal-nuxt": {
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/cookie-universal-nuxt/-/cookie-universal-nuxt-2.1.4.tgz",
+ "integrity": "sha512-xbn4Ozs9S0u2+0mQTZRwGlBL9MGNq8N4H6iGfprR5ufZFCS2hGef++3DBHSmHXZi30Wu3Q7RI/GkNMhz3cecmg==",
+ "requires": {
+ "@types/cookie": "^0.3.3",
+ "cookie-universal": "^2.1.4"
+ }
+ },
"copy-concurrently": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz",
@@ -21546,11 +21362,6 @@
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
"dev": true
},
- "delegate": {
- "version": "3.2.0",
- "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz",
- "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw=="
- },
"delegates": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz",
@@ -23523,14 +23334,6 @@
"minimatch": "~3.0.2"
}
},
- "good-listener": {
- "version": "1.2.2",
- "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz",
- "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=",
- "requires": {
- "delegate": "^3.1.2"
- }
- },
"graceful-fs": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
@@ -24307,11 +24110,6 @@
"is-extglob": "^2.1.1"
}
},
- "is-https": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/is-https/-/is-https-1.0.0.tgz",
- "integrity": "sha512-1adLLwZT9XEXjzhQhZxd75uxf0l+xI9uTSFaZeSESjL3E1eXSPpO+u5RcgqtzeZ1KCaNvtEwZSTO2P4U5erVqQ=="
- },
"is-nan": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.0.tgz",
@@ -24495,11 +24293,6 @@
"integrity": "sha512-fiUvdfCaAXoQTHdKMgTvg6IkecXDcVz6V5rlftUTclF9IKBjMizvSdQaCl/z/6TApDeby5NL+axYou3i0mu1Pg==",
"dev": true
},
- "js-cookie": {
- "version": "2.2.1",
- "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-2.2.1.tgz",
- "integrity": "sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ=="
- },
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@@ -25683,14 +25476,6 @@
"@nuxt/webpack": "2.14.7"
}
},
- "nuxt-clipboard2": {
- "version": "0.2.1",
- "resolved": "https://registry.npmjs.org/nuxt-clipboard2/-/nuxt-clipboard2-0.2.1.tgz",
- "integrity": "sha512-NZl9UpcLjePt3CRhYSmJiv7af5IiI1DRrmesGawapjImmWZ2cO+UqflimIlBqIXjJSnz3ZsaPxX4639UgkxYTA==",
- "requires": {
- "vue-clipboard2": "0.2.1"
- }
- },
"oauth-sign": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
@@ -28077,11 +27862,6 @@
}
}
},
- "select": {
- "version": "1.1.2",
- "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz",
- "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0="
- },
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
@@ -29103,11 +28883,6 @@
"resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz",
"integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q="
},
- "tiny-emitter": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
- "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q=="
- },
"tmp": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
@@ -29585,14 +29360,6 @@
"resolved": "https://registry.npmjs.org/vue-client-only/-/vue-client-only-2.0.0.tgz",
"integrity": "sha512-arhk1wtWAfLsJyxGMoEYhoBowM87/i6HLSG2LH/03Yog6i2d9JEN1peMP0Ceis+/n9DxdenGYZZTxbPPJyHciA=="
},
- "vue-clipboard2": {
- "version": "0.2.1",
- "resolved": "https://registry.npmjs.org/vue-clipboard2/-/vue-clipboard2-0.2.1.tgz",
- "integrity": "sha512-n6ie/0g0bKohmLlC/5ja1esq2Q0jQ5hWmhNSZcvCsWfDeDnVARjl6cBB9p72XV1nlVfuqsZcfV8HTjjZAIlLBA==",
- "requires": {
- "clipboard": "^2.0.0"
- }
- },
"vue-eslint-parser": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-7.1.0.tgz",
diff --git a/package.json b/package.json
index e64a3e6cd..85f2b549b 100644
--- a/package.json
+++ b/package.json
@@ -12,17 +12,16 @@
"lint": "npm run lint:js"
},
"dependencies": {
- "@nuxtjs/auth": "^4.9.1",
"@nuxtjs/axios": "^5.12.5",
"@nuxtjs/dayjs": "^1.2.0",
"@nuxtjs/google-adsense": "^1.3.0",
"@nuxtjs/robots": "^2.4.2",
"@nuxtjs/sitemap": "^2.4.0",
"@nuxtjs/style-resources": "^1.0.0",
+ "cookie-universal-nuxt": "^2.1.4",
"highlight.js": "^10.3.2",
"marked": "^2.0.0",
"nuxt": "^2.14.7",
- "nuxt-clipboard2": "^0.2.1",
"v-tooltip": "^2.0.3",
"vue-click-outside": "^1.1.0",
"vue-highlightjs": "^1.3.3",
diff --git a/pages/dashboard/misc/revoke-token.vue b/pages/dashboard/misc/revoke-token.vue
index 5f0c340c7..7897b0048 100644
--- a/pages/dashboard/misc/revoke-token.vue
+++ b/pages/dashboard/misc/revoke-token.vue
@@ -54,7 +54,7 @@ export default {
},
methods: {
async logout() {
- await this.$auth.setToken('local', false)
+ this.$cookies.remove('auth-token')
await this.$router.replace(
'https://api.modrinth.com/api/v1/auth/init?url=https://modrinth.com/'
)
diff --git a/pages/dashboard/moderation.vue b/pages/dashboard/moderation.vue
index 90d347ef2..210f1aa12 100644
--- a/pages/dashboard/moderation.vue
+++ b/pages/dashboard/moderation.vue
@@ -84,20 +84,18 @@ export default {
ModCard,
},
async asyncData(data) {
- const config = {
- headers: {
- Authorization: data.$auth.getToken('local')
- ? data.$auth.getToken('local')
- : '',
- },
- }
-
const mods = (
- await axios.get(`https://api.modrinth.com/api/v1/moderation/mods`, config)
+ await axios.get(
+ `https://api.modrinth.com/api/v1/moderation/mods`,
+ data.$auth.headers
+ )
).data
const reports = (
- await axios.get(`https://api.modrinth.com/api/v1/report`, config)
+ await axios.get(
+ `https://api.modrinth.com/api/v1/report`,
+ data.$auth.headers
+ )
).data
return {
@@ -107,36 +105,20 @@ export default {
},
methods: {
async changeModStatus(id, status, index) {
- const config = {
- headers: {
- Authorization: this.$auth.getToken('local')
- ? this.$auth.getToken('local')
- : '',
- },
- }
-
await axios.patch(
`https://api.modrinth.com/api/v1/mod/${id}`,
{
status,
},
- config
+ this.$auth.headers
)
this.mods.splice(index, 1)
},
async deleteReport(index) {
- const config = {
- headers: {
- Authorization: this.$auth.getToken('local')
- ? this.$auth.getToken('local')
- : '',
- },
- }
-
await axios.delete(
`https://api.modrinth.com/api/v1/report/${this.reports[index].id}`,
- config
+ this.$auth.headers
)
this.reports.splice(index, 1)
diff --git a/pages/dashboard/notifications.vue b/pages/dashboard/notifications.vue
index cd1a974a4..66162a52e 100644
--- a/pages/dashboard/notifications.vue
+++ b/pages/dashboard/notifications.vue
@@ -53,18 +53,10 @@ export default {
DashboardPage,
},
async asyncData(data) {
- const config = {
- headers: {
- Authorization: data.$auth.getToken('local')
- ? data.$auth.getToken('local')
- : '',
- },
- }
-
const notifications = (
await axios.get(
`https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/notifications`,
- config
+ data.$auth.headers
)
).data
@@ -82,25 +74,19 @@ export default {
method: notification.actions[index].action_route[0].toLowerCase(),
url: `https://api.modrinth.com/api/v1/${notification.actions[index].action_route[1]}`,
headers: {
- Authorization: this.$auth.getToken('local'),
+ Authorization: this.$auth.token,
},
}
await axios(config)
}
- const config = {
- headers: {
- Authorization: this.$auth.getToken('local')
- ? this.$auth.getToken('local')
- : '',
- },
- }
-
await axios.delete(
`https://api.modrinth.com/api/v1/notification/${notification.id}`,
- config
+ this.$auth.headers
)
+
+ this.notifications.splice(index, 1)
} catch (err) {
this.$notify({
group: 'main',
diff --git a/pages/dashboard/projects.vue b/pages/dashboard/projects.vue
index bb0490ba0..7109aa07f 100644
--- a/pages/dashboard/projects.vue
+++ b/pages/dashboard/projects.vue
@@ -46,22 +46,14 @@ export default {
ModCard,
},
async asyncData(data) {
- const config = {
- headers: {
- Authorization: data.$auth.getToken('local')
- ? data.$auth.getToken('local')
- : '',
- },
- }
-
let res = await axios.get(
`https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/mods`,
- config
+ data.$auth.headers
)
res = await axios.get(
`https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(res.data)}`,
- config
+ data.$auth.headers
)
return {
diff --git a/pages/dashboard/settings.vue b/pages/dashboard/settings.vue
index 55e8c9154..3d02ca61f 100644
--- a/pages/dashboard/settings.vue
+++ b/pages/dashboard/settings.vue
@@ -114,7 +114,7 @@ export default {
this.name = this.$auth.user.name
this.email = this.$auth.user.email
this.bio = this.$auth.user.bio
- this.token = this.$auth.getToken('local')
+ this.token = this.$auth.token
},
data() {
return {
@@ -134,7 +134,7 @@ export default {
this.$router.replace('/dashboard/misc/revoke-token')
},
async copyToken() {
- await this.$copyText(this.token)
+ await navigator.clipboard.writeText(this.token)
this.$notify({
group: 'main',
title: 'Copied to clipboard.',
@@ -143,12 +143,6 @@ export default {
})
},
async editProfile() {
- const config = {
- headers: {
- Authorization: this.$auth.getToken('local'),
- },
- }
-
this.$nuxt.$loading.start()
try {
@@ -162,10 +156,12 @@ export default {
await axios.patch(
`https://api.modrinth.com/api/v1/user/${this.$auth.user.id}`,
data,
- config
+ this.$auth.headers
)
- await this.$auth.fetchUser()
+ await this.$store.dispatch('auth/fetchUser', {
+ token: this.$auth.token,
+ })
} catch (err) {
this.$notify({
group: 'main',
@@ -178,18 +174,12 @@ export default {
this.$nuxt.$loading.finish()
},
async deleteAccount() {
- const config = {
- headers: {
- Authorization: this.$auth.getToken('local'),
- },
- }
-
this.$nuxt.$loading.start()
try {
await axios.delete(
`https://api.modrinth.com/api/v1/user/${this.$auth.user.id}`,
- config
+ this.$auth.headers
)
} catch (err) {
this.$notify({
diff --git a/pages/mod/_id/edit.vue b/pages/mod/_id/edit.vue
index 87f965432..2cd71b1df 100644
--- a/pages/mod/_id/edit.vue
+++ b/pages/mod/_id/edit.vue
@@ -314,14 +314,6 @@ export default {
Multiselect,
},
async asyncData(data) {
- const config = {
- headers: {
- Authorization: data.$auth.getToken('local')
- ? data.$auth.getToken('local')
- : '',
- },
- }
-
try {
const [
mod,
@@ -334,7 +326,7 @@ export default {
await Promise.all([
axios.get(
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
- config
+ data.$auth.headers
),
axios.get(`https://api.modrinth.com/api/v1/tag/category`),
axios.get(`https://api.modrinth.com/api/v1/tag/loader`),
@@ -425,12 +417,6 @@ export default {
await this.saveMod()
},
async saveMod() {
- const config = {
- headers: {
- Authorization: this.$auth.getToken('local'),
- },
- }
-
this.$nuxt.$loading.start()
try {
@@ -465,7 +451,7 @@ export default {
await axios.patch(
`https://api.modrinth.com/api/v1/mod/${this.mod.id}`,
data,
- config
+ this.$auth.headers
)
if (this.iconChanged) {
@@ -474,7 +460,7 @@ export default {
this.icon.type.split('/')[this.icon.type.split('/').length - 1]
}`,
this.icon,
- config
+ this.$auth.headers
)
}
diff --git a/pages/mod/_id/index.vue b/pages/mod/_id/index.vue
index beea97799..25c5678d8 100644
--- a/pages/mod/_id/index.vue
+++ b/pages/mod/_id/index.vue
@@ -23,19 +23,11 @@ export default {
components: { ModPage },
auth: false,
async asyncData(data) {
- const config = {
- headers: {
- Authorization: data.$auth.getToken('local')
- ? data.$auth.getToken('local')
- : '',
- },
- }
-
try {
const mod = (
await axios.get(
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
- config
+ data.$auth.headers
)
).data
@@ -50,10 +42,10 @@ export default {
`https://api.modrinth.com/api/v1/mod/${mod.id}/version?featured=true`
),
axios.get(
- data.$auth.loggedIn
+ data.$auth.user
? `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`
: `https://api.modrinth.com`,
- config
+ data.$auth.headers
),
])
).map((it) => it.data)
@@ -63,7 +55,7 @@ export default {
`https://api.modrinth.com/api/v1/users?ids=${JSON.stringify(
members.map((it) => it.user_id)
)}`,
- config
+ data.$auth.headers
)
).data
@@ -73,7 +65,7 @@ export default {
members[index].name = it.username
})
- const currentMember = data.$auth.loggedIn
+ const currentMember = data.$auth.user
? members.find((x) => x.user_id === data.$auth.user.id)
: null
diff --git a/pages/mod/_id/newversion.vue b/pages/mod/_id/newversion.vue
index f4a2a57a1..77ee6d85e 100644
--- a/pages/mod/_id/newversion.vue
+++ b/pages/mod/_id/newversion.vue
@@ -137,19 +137,11 @@ export default {
Multiselect,
},
async asyncData(data) {
- const config = {
- headers: {
- Authorization: data.$auth.getToken('local')
- ? data.$auth.getToken('local')
- : '',
- },
- }
-
try {
const mod = (
await axios.get(
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
- config
+ data.$auth.headers
)
).data
@@ -168,10 +160,10 @@ export default {
axios.get(`https://api.modrinth.com/api/v1/tag/loader`),
axios.get(`https://api.modrinth.com/api/v1/tag/game_version`),
axios.get(
- data.$auth.loggedIn
+ data.$auth.user
? `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`
: `https://api.modrinth.com`,
- config
+ data.$auth.headers
),
])
).map((it) => it.data)
@@ -181,7 +173,7 @@ export default {
`https://api.modrinth.com/api/v1/users?ids=${JSON.stringify(
members.map((it) => it.user_id)
)}`,
- config
+ data.$auth.headers
)
).data
@@ -191,7 +183,7 @@ export default {
members[index].name = it.username
})
- const currentMember = data.$auth.loggedIn
+ const currentMember = data.$auth.user
? members.find((x) => x.user_id === data.$auth.user.id)
: null
@@ -244,7 +236,7 @@ export default {
data: formData,
headers: {
'Content-Type': 'multipart/form-data',
- Authorization: this.$auth.getToken('local'),
+ Authorization: this.$auth.token,
},
})
await this.$router.go(null)
diff --git a/pages/mod/_id/settings.vue b/pages/mod/_id/settings.vue
index 65c527bd0..98cad7db4 100644
--- a/pages/mod/_id/settings.vue
+++ b/pages/mod/_id/settings.vue
@@ -246,19 +246,11 @@ import DropdownIcon from '~/assets/images/utils/dropdown.svg?inline'
export default {
components: { ModPage, DropdownIcon },
async asyncData(data) {
- const config = {
- headers: {
- Authorization: data.$auth.getToken('local')
- ? data.$auth.getToken('local')
- : '',
- },
- }
-
try {
const mod = (
await axios.get(
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
- config
+ data.$auth.headers
)
).data
@@ -266,16 +258,16 @@ export default {
await Promise.all([
axios.get(
`https://api.modrinth.com/api/v1/team/${mod.team}/members`,
- config
+ data.$auth.headers
),
axios.get(
`https://api.modrinth.com/api/v1/mod/${mod.id}/version?featured=true`
),
axios.get(
- data.$auth.loggedIn
+ data.$auth.user
? `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`
: `https://api.modrinth.com`,
- config
+ data.$auth.headers
),
])
).map((it) => it.data)
@@ -286,7 +278,7 @@ export default {
`https://api.modrinth.com/api/v1/users?ids=${JSON.stringify(
members.map((it) => it.user_id)
)}`,
- config
+ data.$auth.headers
),
])
).map((it) => it.data)
@@ -297,7 +289,7 @@ export default {
members[index].name = it.username
})
- const currentMember = data.$auth.loggedIn
+ const currentMember = data.$auth.user
? members.find((x) => x.user_id === data.$auth.user.id)
: null
@@ -333,12 +325,6 @@ export default {
},
methods: {
async inviteTeamMember() {
- const config = {
- headers: {
- Authorization: this.$auth.getToken('local'),
- },
- }
-
this.$nuxt.$loading.start()
try {
@@ -355,7 +341,7 @@ export default {
await axios.post(
`https://api.modrinth.com/api/v1/team/${this.mod.team}/members`,
data,
- config
+ this.auth.headers
)
await this.$router.go(null)
} catch (err) {
@@ -370,18 +356,12 @@ export default {
this.$nuxt.$loading.finish()
},
async removeTeamMember(index) {
- const config = {
- headers: {
- Authorization: this.$auth.getToken('local'),
- },
- }
-
this.$nuxt.$loading.start()
try {
await axios.delete(
`https://api.modrinth.com/api/v1/team/${this.mod.team}/members/${this.members[index].user_id}`,
- config
+ this.$auth.headers
)
await this.$router.go(null)
} catch (err) {
@@ -396,12 +376,6 @@ export default {
this.$nuxt.$loading.finish()
},
async updateTeamMember(index) {
- const config = {
- headers: {
- Authorization: this.$auth.getToken('local'),
- },
- }
-
this.$nuxt.$loading.start()
try {
@@ -413,7 +387,7 @@ export default {
await axios.patch(
`https://api.modrinth.com/api/v1/team/${this.mod.team}/members/${this.members[index].user_id}`,
data,
- config
+ this.$auth.headers
)
await this.$router.go(null)
} catch (err) {
@@ -428,15 +402,9 @@ export default {
this.$nuxt.$loading.finish()
},
async deleteMod() {
- const config = {
- headers: {
- Authorization: this.$auth.getToken('local'),
- },
- }
-
await axios.delete(
`https://api.modrinth.com/api/v1/mod/${this.mod.id}`,
- config
+ this.$auth.headers
)
},
},
diff --git a/pages/mod/_id/version/_version/edit.vue b/pages/mod/_id/version/_version/edit.vue
index ba713918f..ca11a99fc 100644
--- a/pages/mod/_id/version/_version/edit.vue
+++ b/pages/mod/_id/version/_version/edit.vue
@@ -126,19 +126,11 @@ export default {
},
auth: false,
async asyncData(data) {
- const config = {
- headers: {
- Authorization: data.$auth.getToken('local')
- ? data.$auth.getToken('local')
- : '',
- },
- }
-
try {
const mod = (
await axios.get(
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
- config
+ data.$auth.headers
)
).data
@@ -159,10 +151,10 @@ export default {
axios.get(`https://api.modrinth.com/api/v1/tag/loader`),
axios.get(`https://api.modrinth.com/api/v1/tag/game_version`),
axios.get(
- data.$auth.loggedIn
+ data.$auth.user
? `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`
: `https://api.modrinth.com`,
- config
+ data.$auth.headers
),
])
).map((it) => it.data)
@@ -172,7 +164,7 @@ export default {
`https://api.modrinth.com/api/v1/users?ids=${JSON.stringify(
members.map((it) => it.user_id)
)}`,
- config
+ data.$auth.headers
)
).data
@@ -192,7 +184,7 @@ export default {
primaryFile = version.files[0]
}
- const currentMember = data.$auth.loggedIn
+ const currentMember = data.$auth.user
? members.find((x) => x.user_id === data.$auth.user.id)
: null
@@ -221,21 +213,13 @@ export default {
},
methods: {
async saveVersion() {
- const config = {
- headers: {
- Authorization: this.$auth.getToken('local')
- ? this.$auth.getToken('local')
- : '',
- },
- }
-
this.$nuxt.$loading.start()
try {
await axios.patch(
`https://api.modrinth.com/api/v1/version/${this.version.id}`,
this.version,
- config
+ this.$auth.headers
)
await this.$router.replace(
`/mod/${this.mod.id}/version/${this.version.id}`
diff --git a/pages/mod/_id/version/_version/index.vue b/pages/mod/_id/version/_version/index.vue
index 0e8e880f8..7aceb4e39 100644
--- a/pages/mod/_id/version/_version/index.vue
+++ b/pages/mod/_id/version/_version/index.vue
@@ -29,7 +29,7 @@