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 untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 19 additions and 15 deletions

View File

@ -265,6 +265,12 @@
router.push({name: 'login'}) 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() { created() {
this.$store.dispatch('config/update') this.$store.dispatch('config/update')
this.$store.dispatch('auth/checkAuth') this.$store.dispatch('auth/checkAuth')

View File

@ -9,16 +9,19 @@
> >
Import your data into Vikunja Import your data into Vikunja
</router-link> </router-link>
<TaskOverview :show-all="true"/> <ShowTasks :show-all="true"/>
</div> </div>
</template> </template>
<script> <script>
import router from '../router'
import {mapState} from 'vuex' import {mapState} from 'vuex'
import ShowTasks from './tasks/ShowTasks'
export default { export default {
name: "Home", name: 'Home',
components: {
ShowTasks,
},
data() { data() {
return { return {
loading: false, loading: false,
@ -26,12 +29,6 @@
tasks: [] 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({ computed: mapState({
migratorsEnabled: state => state.config.availableMigrators !== null && state.config.availableMigrators.length > 0, migratorsEnabled: state => state.config.availableMigrators !== null && state.config.availableMigrators.length > 0,
authenticated: state => state.auth.authenticated, authenticated: state => state.auth.authenticated,

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="content has-text-centered"> <div class="content has-text-centered">
<TaskOverview <ShowTasks
:start-date="startDate" :start-date="startDate"
:end-date="endDate" :end-date="endDate"
/> />
@ -8,8 +8,13 @@
</template> </template>
<script> <script>
import ShowTasks from './ShowTasks'
export default { export default {
name: "ShowTasksInRange", name: 'ShowTasksInRange',
components: {
ShowTasks,
},
data() { data() {
return { return {
startDate: new Date(this.$route.params.startDateUnix), 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' import Modal from './components/modal/Modal'
Vue.component('modal', Modal) Vue.component('modal', Modal)
// Register the task overview component
import TaskOverview from './components/tasks/ShowTasks'
Vue.component('TaskOverview', TaskOverview)
// Add CSS // Add CSS
import './styles/vikunja.scss' import './styles/vikunja.scss'