From 1e0d118930253054e3e480506ba265c2586af1b1 Mon Sep 17 00:00:00 2001 From: Jai A Date: Mon, 29 Mar 2021 19:15:18 -0700 Subject: [PATCH] Final auth fix --- middleware/auth.js | 18 +++++++++--------- pages/dashboard/follows.vue | 10 +--------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/middleware/auth.js b/middleware/auth.js index 68d31e7d1..ee800dc7e 100644 --- a/middleware/auth.js +++ b/middleware/auth.js @@ -1,5 +1,10 @@ export default async function (context) { if (!context.from) { + if (context.app.$cookies.get('auth-token-reset')) { + context.app.$cookies.removeAll() + return + } + if (context.route.query.code) { context.app.$cookies.set('auth-token', context.route.query.code, { secure: true, @@ -7,15 +12,10 @@ export default async function (context) { httpOnly: true, }) - return context.redirect(context.route.path) - } - - if (context.app.$cookies.get('auth-token-reset')) { - context.app.$cookies.removeAll() - return - } - - if (context.app.$cookies.get('auth-token')) { + await context.store.dispatch('auth/fetchUser', { + token: context.route.query.code, + }) + } else if (context.app.$cookies.get('auth-token')) { const cookie = context.app.$cookies.get('auth-token') await context.store.dispatch('auth/fetchUser', { token: cookie }) diff --git a/pages/dashboard/follows.vue b/pages/dashboard/follows.vue index 4c139553a..d2741ba93 100644 --- a/pages/dashboard/follows.vue +++ b/pages/dashboard/follows.vue @@ -48,17 +48,9 @@ export default { FollowIcon, }, async asyncData(data) { - const config = { - headers: { - Authorization: data.$auth.getToken('local') - ? data.$auth.getToken('local') - : '', - }, - } - const res = await axios.get( `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`, - config + data.$auth.headers ) const mods = (