From ce277b64eeada25001af0a9c4c824616849a51f9 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 21 Jun 2020 17:42:08 +0200 Subject: [PATCH] Only load tasks when the user is authenticated --- src/views/tasks/ShowTasks.vue | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/views/tasks/ShowTasks.vue b/src/views/tasks/ShowTasks.vue index d90c8c2f..3c4a5e06 100644 --- a/src/views/tasks/ShowTasks.vue +++ b/src/views/tasks/ShowTasks.vue @@ -18,6 +18,7 @@ import TaskService from '../../services/task' import SingleTaskInList from '../../components/tasks/partials/singleTaskInList' import {HAS_TASKS} from '../../store/mutation-types' + import {mapState} from 'vuex' export default { name: 'ShowTasks', @@ -43,8 +44,18 @@ watch: { '$route': 'loadPendingTasks', }, + computed: mapState({ + userAuthenticated: state => state.auth.authenticated, + }), methods: { loadPendingTasks() { + // Since this route is authentication only, users would get an error message if they access the page unauthenticated. + // Since this component is mounted as the home page before unauthenticated users get redirected + // to the login page, they will almost always see the error message. + if (!this.userAuthenticated) { + return + } + const params = { sort_by: ['due_date_unix', 'id'], order_by: ['desc', 'desc'],