mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2025-03-29 21:11:51 +03:00
fix: logout #286
This commit is contained in:
parent
d8e2610419
commit
912123098e
3 changed files with 9 additions and 13 deletions
|
@ -134,7 +134,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
logout() {
|
logout() {
|
||||||
this.$store.commit('LOGOUT')
|
this.$store.commit('LOGOUT')
|
||||||
this.$router.push('/login')
|
this.$router.push({ name: 'login' })
|
||||||
},
|
},
|
||||||
toggleSpeed() {
|
toggleSpeed() {
|
||||||
qbit.toggleSpeedLimitsMode()
|
qbit.toggleSpeedLimitsMode()
|
||||||
|
|
|
@ -25,19 +25,14 @@ const router = new Router({
|
||||||
name: 'login',
|
name: 'login',
|
||||||
component: Login,
|
component: Login,
|
||||||
meta: {
|
meta: {
|
||||||
public: true, // Allow access to even if not logged in
|
public: true // Allow access to even if not logged in }
|
||||||
onlyWhenLoggedOut: true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
const isPublic = to.matched.some(record => record.meta.public)
|
const isPublic = to.matched.some(record => record.meta.public)
|
||||||
const onlyWhenLoggedOut = to.matched.some(
|
|
||||||
record => record.meta.onlyWhenLoggedOut
|
|
||||||
)
|
|
||||||
const authenticated = isAuthenticated()
|
const authenticated = isAuthenticated()
|
||||||
|
|
||||||
if (!isPublic && !authenticated) {
|
if (!isPublic && !authenticated) {
|
||||||
|
@ -48,12 +43,6 @@ router.beforeEach(async (to, from, next) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not allow user to visit login page or register page
|
|
||||||
// if they are logged in
|
|
||||||
if (authenticated && onlyWhenLoggedOut) {
|
|
||||||
return next('/')
|
|
||||||
}
|
|
||||||
|
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,8 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mdiLock, mdiAccount } from '@mdi/js'
|
import { mdiLock, mdiAccount } from '@mdi/js'
|
||||||
|
import { isAuthenticated } from '@/services/auth.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Login',
|
name: 'Login',
|
||||||
data() {
|
data() {
|
||||||
|
@ -58,6 +60,11 @@ export default {
|
||||||
mdiLock, mdiAccount
|
mdiLock, mdiAccount
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
if (isAuthenticated()) {
|
||||||
|
this.$router.push('/')
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async Login() {
|
async Login() {
|
||||||
const authenticated = await this.$store.dispatch('LOGIN', {
|
const authenticated = await this.$store.dispatch('LOGIN', {
|
||||||
|
|
Loading…
Add table
Reference in a new issue