Skip to content

Commit

Permalink
Community profile permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexPopaCode4 committed Dec 13, 2024
1 parent 3183962 commit 061ae5a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/Concerns/HasPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function hasAccessToNomenclature(): bool
return (bool) $this->permissions?->admin_permissions->contains(AdminPermission::CAN_CHANGE_NOMENCLATURE);
}

public function hasAccessToCommunity(): bool
public function canChangeOrganizationProfile(): bool
{
if ($this->isAdmin()) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ class CommunityProfileResource extends Resource

protected static ?int $navigationSort = 21;

public static function canAccess(): bool
{
return auth()->user()->canChangeOrganizationProfile();
}

public static function getNavigationGroup(): ?string
{
return __('navigation.community._group');
Expand Down
10 changes: 5 additions & 5 deletions app/Policies/CommunityProfilePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@ class CommunityProfilePolicy
*/
public function viewAny(User $user): bool
{
return $user->hasAccessToCommunity();
return true;
}

/**
* Determine whether the user can view the model.
*/
public function view(User $user, CommunityProfile $communityProfile): bool
{
return $user->hasAccessToCommunity();
return true;
}

/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->hasAccessToCommunity();
return true;
}

/**
* Determine whether the user can update the model.
*/
public function update(User $user, CommunityProfile $communityProfile): bool
{
return $user->hasAccessToCommunity();
return true;
}

/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, CommunityProfile $communityProfile): bool
{
return $user->hasAccessToCommunity();
return true;
}

/**
Expand Down

0 comments on commit 061ae5a

Please sign in to comment.