-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: block pending users from seeing approved user only content (#1937)
* fix: block pending users from seeing approved user only content * fix: update logic for who can view published content * fix: add more tests and update actingAs usages * fix: fix a mistake * fix: add new policy for viewing owned content and update projects view policy * fix: update canViewOwnedContent rule to block individuals * fix: update canViewOwnedContent rule for individuals * fix: update based on PR feedback * fix: remove view all projects from my-project when not approved * fix: add some test cases for the changes
- Loading branch information
Showing
12 changed files
with
846 additions
and
821 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace App\Traits; | ||
|
||
use App\Enums\UserContext; | ||
use App\Models\User; | ||
|
||
trait UserCanViewOwnedContent | ||
{ | ||
public function canViewOwnedContent(User $user): bool | ||
{ | ||
if ($user->isAdministrator()) { | ||
return true; | ||
} | ||
|
||
if ($user->context === 'individual' && ! $user->oriented_at) { | ||
return false; | ||
} | ||
|
||
return | ||
$user->hasVerifiedEmail() && | ||
in_array( | ||
$user->context, | ||
[ | ||
UserContext::Individual->value, | ||
UserContext::Organization->value, | ||
UserContext::RegulatedOrganization->value, | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.