Final auth fix

This commit is contained in:
Jai A
2021-03-29 19:15:18 -07:00
parent 723e6dd13f
commit 1e0d118930
2 changed files with 10 additions and 18 deletions

View File

@@ -1,5 +1,10 @@
export default async function (context) { export default async function (context) {
if (!context.from) { if (!context.from) {
if (context.app.$cookies.get('auth-token-reset')) {
context.app.$cookies.removeAll()
return
}
if (context.route.query.code) { if (context.route.query.code) {
context.app.$cookies.set('auth-token', context.route.query.code, { context.app.$cookies.set('auth-token', context.route.query.code, {
secure: true, secure: true,
@@ -7,15 +12,10 @@ export default async function (context) {
httpOnly: true, httpOnly: true,
}) })
return context.redirect(context.route.path) await context.store.dispatch('auth/fetchUser', {
} token: context.route.query.code,
})
if (context.app.$cookies.get('auth-token-reset')) { } else if (context.app.$cookies.get('auth-token')) {
context.app.$cookies.removeAll()
return
}
if (context.app.$cookies.get('auth-token')) {
const cookie = context.app.$cookies.get('auth-token') const cookie = context.app.$cookies.get('auth-token')
await context.store.dispatch('auth/fetchUser', { token: cookie }) await context.store.dispatch('auth/fetchUser', { token: cookie })

View File

@@ -48,17 +48,9 @@ export default {
FollowIcon, FollowIcon,
}, },
async asyncData(data) { async asyncData(data) {
const config = {
headers: {
Authorization: data.$auth.getToken('local')
? data.$auth.getToken('local')
: '',
},
}
const res = await axios.get( const res = await axios.get(
`https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`, `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`,
config data.$auth.headers
) )
const mods = ( const mods = (