Only load tasks when the user is authenticated
This commit is contained in:
parent
8a7ecfa3bb
commit
ce277b64ee
1 changed files with 11 additions and 0 deletions
|
@ -18,6 +18,7 @@
|
||||||
import TaskService from '../../services/task'
|
import TaskService from '../../services/task'
|
||||||
import SingleTaskInList from '../../components/tasks/partials/singleTaskInList'
|
import SingleTaskInList from '../../components/tasks/partials/singleTaskInList'
|
||||||
import {HAS_TASKS} from '../../store/mutation-types'
|
import {HAS_TASKS} from '../../store/mutation-types'
|
||||||
|
import {mapState} from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ShowTasks',
|
name: 'ShowTasks',
|
||||||
|
@ -43,8 +44,18 @@
|
||||||
watch: {
|
watch: {
|
||||||
'$route': 'loadPendingTasks',
|
'$route': 'loadPendingTasks',
|
||||||
},
|
},
|
||||||
|
computed: mapState({
|
||||||
|
userAuthenticated: state => state.auth.authenticated,
|
||||||
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
loadPendingTasks() {
|
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 = {
|
const params = {
|
||||||
sort_by: ['due_date_unix', 'id'],
|
sort_by: ['due_date_unix', 'id'],
|
||||||
order_by: ['desc', 'desc'],
|
order_by: ['desc', 'desc'],
|
||||||
|
|
Loading…
Reference in a new issue