mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
verify event permission in UI, fix #213
This commit is contained in:
parent
d3b6adf4e0
commit
593cf6c6d6
1 changed files with 19 additions and 3 deletions
|
@ -91,17 +91,33 @@ export default {
|
|||
WhereInput,
|
||||
DateInput
|
||||
},
|
||||
validate({ store }) {
|
||||
return (store.state.auth.loggedIn || store.state.settings.allow_anon_event)
|
||||
validate({ store, params, error }) {
|
||||
// should we allow anon event?
|
||||
if(!store.state.settings.allow_anon_event && !store.state.auth.loggedIn) {
|
||||
return error({ statusCode: 401, message: 'Not allowed'})
|
||||
}
|
||||
|
||||
// do not allow edit to anon users
|
||||
if (params.edit && !store.state.auth.loggedIn) {
|
||||
return error({ statusCode: 401, message: 'Not allowed'})
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
},
|
||||
async asyncData({ params, $axios, error }) {
|
||||
async asyncData({ params, $axios, error, $auth, store }) {
|
||||
if (params.edit) {
|
||||
|
||||
const data = { event: { place: {}, media: [] } }
|
||||
data.id = params.edit
|
||||
data.edit = true
|
||||
let event
|
||||
try {
|
||||
event = await $axios.$get('/event/' + data.id)
|
||||
if (!$auth.user.is_admin && $auth.user.id !== event.userId) {
|
||||
error({ statusCode: 401, message: 'Not allowed' })
|
||||
return {}
|
||||
}
|
||||
} catch (e) {
|
||||
error({ statusCode: 404, message: 'Event not found!' })
|
||||
return {}
|
||||
|
|
Loading…
Reference in a new issue