No longer need to override authorization manager

This commit is contained in:
2023-06-07 11:12:32 +01:00
parent de85fd6e47
commit 58a1b2d316
2 changed files with 4 additions and 102 deletions

View File

@@ -19,7 +19,6 @@ use UserFrosting\Sprinkle\Organisations\Database\Models\User;
use UserFrosting\Sprinkle\Organisations\Twig\OrganisationsExtension;
use UserFrosting\Sprinkle\Organisations\Repository\OrganisationApprovalRepository;
use UserFrosting\Sprinkle\Organisations\Repository\OrganisationMembershipApprovalRepository;
use UserFrosting\Sprinkle\Organisations\Authorize\AuthorizationManager;
/**
@@ -61,9 +60,6 @@ class ServicesProvider
* @return \UserFrosting\Sprinkle\Core\Util\ClassMapper
*/
$container->extend('authorizer', function ($authorizer, $c) {
$new_authorizer = new AuthorizationManager($c, $authorizer->getCallbacks());
/*
* Check if all $user is a member of $organisation.
*
@@ -71,7 +67,7 @@ class ServicesProvider
* @param int $organisation_id the id of the target organisation.
* @return bool true if $user is a member of $organisation.
*/
$new_authorizer->addCallback('is_organisation_member', function ($user_id, $organisation_id, $explicit = false) {
$authorizer->addCallback('is_organisation_member', function ($user_id, $organisation_id, $explicit = false) {
$query = Capsule::table('organisation_members')
->where('user_id', $user_id)
->where('organisation_id', $organisation_id)
@@ -91,7 +87,7 @@ class ServicesProvider
* @param int $organisation_id the id of the target organisation.
* @return bool true if $user is an administrator of $organisation.
*/
$new_authorizer->addCallback('is_organisation_admin', function ($user_id, $organisation_id) {
$authorizer->addCallback('is_organisation_admin', function ($user_id, $organisation_id) {
return Capsule::table('organisation_members')
->where('user_id', $user_id)
->where('organisation_id', $organisation_id)
@@ -107,7 +103,7 @@ class ServicesProvider
* @param bool $check_is_admin also check if A can administrate B.
* @return bool true if $user_A_id in an organisation with $user_B_id in.
*/
$new_authorizer->addCallback('has_matching_organisation', function ($user_A_id, $user_B_id, $check_is_admin = false) {
$authorizer->addCallback('has_matching_organisation', function ($user_A_id, $user_B_id, $check_is_admin = false) {
$user_A = User::findInt($user_A_id);
$user_B = User::findInt($user_B_id);
@@ -128,7 +124,7 @@ class ServicesProvider
return false;
});
return $new_authorizer;
return $authorizer;
});
/*