(permission, { ownerId, permissions })
| 4 | } |
| 5 | |
| 6 | export function hasPermission (permission, { ownerId, permissions }) { |
| 7 | if (me.id === ownerId) return true |
| 8 | if (me.isAdmin()) return true |
| 9 | if (permission !== 'read' && permission !== 'write') return false |
| 10 | return !!(permissions || []).find(p => p.target === me.id && p.access === permission) |
| 11 | } |
| 12 | |
| 13 | export function hasSharedWriteAccessPermission (classroom) { |
| 14 | return (classroom.permissions || []).find((p) => p.target === me.get('_id') && p.access === 'write') |