This commit is contained in:
lesion 2019-07-04 01:09:35 +02:00
parent 5139d0b323
commit 15a763324f
3 changed files with 9 additions and 5 deletions

View file

@ -95,9 +95,13 @@ export default {
console.error(e)
}
},
async asyncData ( { $axios, params }) {
const event = await $axios.$get(`/event/${params.id}`)
return { event, id: params.id }
async asyncData ( { $axios, params, error }) {
try {
const event = await $axios.$get(`/event/${params.id}`)
return { event, id: params.id }
} catch(e) {
error({ statusCode: 404, message: 'Event not found'})
}
},
computed: {
...mapGetters(['filteredEvents']),

View file

@ -84,7 +84,7 @@ const eventController = {
// TODO retrieve next/prev event also
// select id, start_datetime, title from events where start_datetime > (select start_datetime from events where id=89) order by start_datetime limit 20;
async get(req, res) {
const is_admin = req.user.is_admin
const is_admin = req.user && req.user.is_admin
const id = req.params.event_id
let event = await Event.findByPk(id, {
plain: true,

View file

@ -87,7 +87,7 @@ api.get('/settings', settingsController.getAllRequest)
api.post('/settings', jwt, fillUser, isAdmin, settingsController.setRequest)
// get event
api.get('/event/:event_id', eventController.get)
api.get('/event/:event_id', jwt, fillUser, eventController.get)
// confirm event
api.get('/event/confirm/:event_id', jwt, isAuth, isAdmin, eventController.confirm)