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
No known key found for this signature in database
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'