Allow users to see their own organisation pages

This commit is contained in:
2022-02-08 16:13:43 +00:00
parent 2d701760c3
commit b3c51527a0
9 changed files with 275 additions and 6 deletions

View File

@@ -27,6 +27,7 @@ class OrganisationPermissions extends BaseSeed
public function run()
{
// We require the default roles
Seeder::execute('DefaultPermissions');
Seeder::execute('DefaultRoles');
Seeder::execute('OrganisationRoles');
@@ -56,6 +57,12 @@ class OrganisationPermissions extends BaseSeed
'conditions' => "in(property,['name','slug','description','members'])",
'description' => 'View certain properties of any organisation.',
]),
'view_organisation_field_own' => new Permission([
'slug' => 'view_organisation_field',
'name' => 'View own organisation',
'conditions' => "is_organisation_member(self.id,organisation.id) & in(property,['name','slug','description','members'])",
'description' => 'View certain properties of own organisation.',
]),
'update_organisation_field' => new Permission([
'slug' => 'update_organisation_field',
'name' => 'Edit organisation',
@@ -80,6 +87,12 @@ class OrganisationPermissions extends BaseSeed
'conditions' => 'always()',
'description' => 'View the organisation page of any organisation.',
]),
'uri_organisation_own' => new Permission([
'slug' => 'uri_organisation',
'name' => 'View own organisation',
'conditions' => 'is_organisation_member(self.id,organisation.id)',
'description' => 'View the organisation page of an organisation you are a member of.',
]),
'uri_organisations' => new Permission([
'slug' => 'uri_organisations',
'name' => 'Organisation management page',
@@ -144,6 +157,13 @@ class OrganisationPermissions extends BaseSeed
$permissions['uri_organisation']->id,
]);
}
$roleUser = Role::where('slug', 'user')->first();
if ($roleUser) {
$roleUser->permissions()->syncWithoutDetaching([
$permissions['uri_organisation_own']->id,
$permissions['view_organisation_field_own']->id,
]);
}
}
}