mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2024-11-28 21:18:54 +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: {
|
||||
logout() {
|
||||
this.$store.commit('LOGOUT')
|
||||
this.$router.push('/login')
|
||||
this.$router.push({ name: 'login' })
|
||||
},
|
||||
toggleSpeed() {
|
||||
qbit.toggleSpeedLimitsMode()
|
||||
|
|
|
@ -25,19 +25,14 @@ const router = new Router({
|
|||
name: 'login',
|
||||
component: Login,
|
||||
meta: {
|
||||
public: true, // Allow access to even if not logged in
|
||||
onlyWhenLoggedOut: true
|
||||
public: true // Allow access to even if not logged in }
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
})
|
||||
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
const isPublic = to.matched.some(record => record.meta.public)
|
||||
const onlyWhenLoggedOut = to.matched.some(
|
||||
record => record.meta.onlyWhenLoggedOut
|
||||
)
|
||||
const authenticated = isAuthenticated()
|
||||
|
||||
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()
|
||||
})
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
|
||||
<script>
|
||||
import { mdiLock, mdiAccount } from '@mdi/js'
|
||||
import { isAuthenticated } from '@/services/auth.js'
|
||||
|
||||
export default {
|
||||
name: 'Login',
|
||||
data() {
|
||||
|
@ -58,6 +60,11 @@ export default {
|
|||
mdiLock, mdiAccount
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (isAuthenticated()) {
|
||||
this.$router.push('/')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async Login() {
|
||||
const authenticated = await this.$store.dispatch('LOGIN', {
|
||||
|
|
Loading…
Reference in a new issue