Feature/permissions fixes

this is too much logic for a template