Skip to content

Commit

Permalink
Merge pull request #414 from code4romania/397-specialist-general-inco…
Browse files Browse the repository at this point in the history
…rrect-user-permissions-in-the-comunitatea-sunrise-section

Community profile permissions
  • Loading branch information
gheorghelupu17 authored Dec 17, 2024
2 parents e42f700 + 4f72acb commit 3acc999
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 3acc999

Please sign in to comment.