...
 
Commits (4)
......@@ -78,7 +78,7 @@
console.debug('created annotation', annotation)
if (detail.isPublic) {
console.debug('make annotation public')
await this.$store.dispatch('acl/set', {uuid: annotation._uuid, role: 'public', permissions: ['get']})
await this.$store.dispatch('acl/set', {id: annotation.id, role: 'public', permissions: ['get']})
}
this.$store.commit('conversions/removeJobDetail', jobId)
this.$root.$emit('updateVideos')
......
......@@ -18,16 +18,16 @@ class ACLHelpers {
static async updateACL (context) {
console.debug('setting acl...', context.acl)
if (this.acl.public) {
await this.setACL('acl/set', { role: 'public', uuid: context.timeline._uuid, permissions: ['get'] }, context.acl.recursive)
await this.setACL('acl/set', { role: 'public', id: context.timeline.id, permissions: ['get'] }, context.acl.recursive)
}
else {
await this.setACL('acl/remove', { role: 'public', uuid: context.timeline._uuid, permission: 'get' }, context.acl.recursive)
await this.setACL('acl/remove', { role: 'public', id: context.timeline.id, permission: 'get' }, context.acl.recursive)
}
if (this.acl.group) {
await this.setACL('acl/set', { role: context.acl.group, uuid: context.timeline._uuid, permissions: ['get'] }, context.acl.recursive)
await this.setACL('acl/set', { role: context.acl.group, id: context.timeline.id, permissions: ['get'] }, context.acl.recursive)
}
if (this.acl.group_remove) {
await this.setACL('acl/remove', { role: context.acl.group_remove, uuid: context.timeline._uuid, permission: 'get' }, context.acl.recursive)
await this.setACL('acl/remove', { role: context.acl.group_remove, id: context.timeline.id, permission: 'get' }, context.acl.recursive)
}
this.$store.commit('notifications/addMessage', {
body: 'messages.acl_updated',
......
......@@ -85,16 +85,16 @@
this.$q.loading.show()
console.debug('setting acl...', this.acl, this.resourceName)
if (this.acl.public) {
await this.setACL('acl/set', { role: 'public', uuid: this.resourceName, id: this.resourceName, permissions: ['get'] }, this.acl.recursive)
await this.setACL('acl/set', { role: 'public', id: this.resourceName, permissions: ['get'] }, this.acl.recursive)
}
else {
await this.setACL('acl/remove', { role: 'public', uuid: this.resourceName, id: this.resourceName, permission: 'get' }, this.acl.recursive)
await this.setACL('acl/remove', { role: 'public', id: this.resourceName, permission: 'get' }, this.acl.recursive)
}
if (this.acl.group) {
await this.setACL('acl/set', { role: this.acl.group, uuid: this.resourceName, id: this.resourceName, permissions: ['get'] }, this.acl.recursive)
await this.setACL('acl/set', { role: this.acl.group, id: this.resourceName, permissions: ['get'] }, this.acl.recursive)
}
if (this.acl.group_remove) {
await this.setACL('acl/remove', { role: this.acl.group_remove, uuid: this.resourceName, id: this.resourceName, permission: 'get' }, this.acl.recursive)
await this.setACL('acl/remove', { role: this.acl.group_remove, id: this.resourceName, permission: 'get' }, this.acl.recursive)
}
this.$q.loading.hide()
this.$store.commit('notifications/addMessage', {
......
import axios from 'axios'
import * as utils from 'mbjs-utils'
import parseURI from 'mbjs-data-models/src/lib/parse-uri'
const acl = {
namespaced: true,
......@@ -8,39 +6,29 @@ const acl = {
resources: []
},
actions: {
async set (context, { role, uuid, id, permissions }) {
async set (context, { role, id, permissions }) {
const headers = {
Authorization: `Bearer ${localStorage.getItem('access_token')}`
}
if (!uuid && id) uuid = parseURI(id).uuid
if (!utils.uuid.isUUID(uuid)) {
const query = `?role=${encodeURIComponent(role)}&resource=${encodeURIComponent(uuid)}`
await axios.put(`${process.env.API_HOST}/acl${query}`, permissions, { headers })
}
else await axios.put(`${process.env.API_HOST}/acl/${role}/${uuid}`, permissions, { headers })
const query = `?role=${encodeURIComponent(role)}&resource=${encodeURIComponent(id)}`
await axios.put(`${process.env.API_HOST}/acl${query}`, permissions, { headers })
},
async remove (context, { role, uuid, id, permission }) {
async remove (context, { role, id, permission }) {
const headers = {
Authorization: `Bearer ${localStorage.getItem('access_token')}`
}
if (!uuid && id) uuid = parseURI(id).uuid
if (!utils.uuid.isUUID(uuid)) {
const query = `?role=${encodeURIComponent(role)}&resource=${encodeURIComponent(uuid)}&permission=${encodeURIComponent(permission)}`
await axios.delete(`${process.env.API_HOST}/acl${query}`, { headers })
}
else await axios.delete(`${process.env.API_HOST}/acl/${role}/${uuid}/${permission}`, { headers })
const query = `?role=${encodeURIComponent(role)}&resource=${encodeURIComponent(id)}` +
`&permission=${encodeURIComponent(permission)}`
await axios.delete(`${process.env.API_HOST}/acl${query}`, { headers })
},
async isRoleAllowed (context, { role, uuid, id, permission }) {
async isRoleAllowed (context, { role, id, permission }) {
const headers = {
Authorization: `Bearer ${localStorage.getItem('access_token')}`
}
if (!uuid && id) uuid = parseURI(id).uuid
let permissions
if (!utils.uuid.isUUID(uuid)) {
const query = `?role=${encodeURIComponent(role)}&resource=${encodeURIComponent(uuid)}&permission=${encodeURIComponent(permission)}`
permissions = await axios.get(`${process.env.API_HOST}/acl${query}`, { headers })
}
else permissions = await axios.get(`${process.env.API_HOST}/acl/${role}/${uuid}/${permission}`, { headers })
const query = `?role=${encodeURIComponent(role)}&resource=${encodeURIComponent(id)}` +
`&permission=${encodeURIComponent(permission)}`
permissions = await axios.get(`${process.env.API_HOST}/acl${query}`, { headers })
return permissions.data
}
}
......