1
0

Fix auth again

This commit is contained in:
Jai A
2021-03-29 18:34:57 -07:00
parent e941af0905
commit 723e6dd13f
3 changed files with 9 additions and 8 deletions

View File

@@ -162,10 +162,9 @@ export default {
hideDropdown() {
this.isDropdownOpen = false
},
logout() {
this.$auth.user = null
this.$cookies.remove('auth-token')
this.$router.go(null)
async logout() {
this.$cookies.set('auth-token-reset', true)
await this.$router.go(null)
},
changeTheme() {
this.$colorMode.preference =

View File

@@ -10,12 +10,15 @@ export default async function (context) {
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')) {
const cookie = context.app.$cookies.get('auth-token')
await context.store.dispatch('auth/fetchUser', { token: cookie })
} else {
context.$auth.user = null
}
}

View File

@@ -54,8 +54,7 @@ export default {
},
methods: {
async logout() {
this.$auth.user = null
this.$cookies.remove('auth-token')
this.$cookies.set('auth-token-reset', true)
await this.$router.replace(
'https://api.modrinth.com/api/v1/auth/init?url=https://modrinth.com/'
)