Fix trying to load the current tasks even when not logged in (Fixes #133)

This commit is contained in:
kolaente 2020-05-12 15:08:17 +02:00
parent cc46809639
commit 0dc4e6b95d
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 19 additions and 15 deletions

View File

@ -265,6 +265,12 @@
router.push({name: 'login'})
}
},
beforeCreate() {
// Check if the user is already logged in, if so, redirect them to the homepage
if (!this.userAuthenticated && this.$route.name !== 'login') {
router.push({name: 'login'})
}
},
created() {
this.$store.dispatch('config/update')
this.$store.dispatch('auth/checkAuth')

View File

@ -9,16 +9,19 @@
>
Import your data into Vikunja
</router-link>
<TaskOverview :show-all="true"/>
<ShowTasks :show-all="true"/>
</div>
</template>
<script>
import router from '../router'
import {mapState} from 'vuex'
import ShowTasks from './tasks/ShowTasks'
export default {
name: "Home",
name: 'Home',
components: {
ShowTasks,
},
data() {
return {
loading: false,
@ -26,12 +29,6 @@
tasks: []
}
},
beforeMount() {
// Check if the user is already logged in, if so, redirect him to the homepage
if (!this.authenticated) {
router.push({name: 'login'})
}
},
computed: mapState({
migratorsEnabled: state => state.config.availableMigrators !== null && state.config.availableMigrators.length > 0,
authenticated: state => state.auth.authenticated,

View File

@ -1,6 +1,6 @@
<template>
<div class="content has-text-centered">
<TaskOverview
<ShowTasks
:start-date="startDate"
:end-date="endDate"
/>
@ -8,8 +8,13 @@
</template>
<script>
import ShowTasks from './ShowTasks'
export default {
name: "ShowTasksInRange",
name: 'ShowTasksInRange',
components: {
ShowTasks,
},
data() {
return {
startDate: new Date(this.$route.params.startDateUnix),

View File

@ -14,10 +14,6 @@ if(window.API_URL.substr(window.API_URL.length - 1, window.API_URL.length) === '
import Modal from './components/modal/Modal'
Vue.component('modal', Modal)
// Register the task overview component
import TaskOverview from './components/tasks/ShowTasks'
Vue.component('TaskOverview', TaskOverview)
// Add CSS
import './styles/vikunja.scss'