-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AIDAPP-302]: Prevent users from being able to edit service requests …
…of types if they are not managers (#279) * Prevent users from viewing service requests of types that they are not managers or auditors of * removed pysh file * Prevent users from being able to edit service requests of types if they are not managers * fix test cases * Resolve suggestions * Fix test case issue * chore: fix enforcement of copyright on all files * chore: fix code style * Ensure the type is taken into account for the respondent check Signed-off-by: Kevin Ullyott <kevin.ullyott@canyongbs.com> * Fix bulk delete check Signed-off-by: Kevin Ullyott <kevin.ullyott@canyongbs.com> * Fix the policy Signed-off-by: Kevin Ullyott <kevin.ullyott@canyongbs.com> --------- Signed-off-by: Kevin Ullyott <kevin.ullyott@canyongbs.com> Co-authored-by: ankit-canyon <ankit-canyon@users.noreply.github.com> Co-authored-by: joelicatajr <joelicatajr@users.noreply.github.com> Co-authored-by: Kevin Ullyott <kevin.ullyott@canyongbs.com>
- Loading branch information
1 parent
07a6f28
commit a4da371
Showing
10 changed files
with
529 additions
and
28 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
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
69 changes: 69 additions & 0 deletions
69
app-modules/service-management/src/Rules/ManagedServiceRequestType.php
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,69 @@ | ||
<?php | ||
|
||
/* | ||
<COPYRIGHT> | ||
Copyright © 2016-2024, Canyon GBS LLC. All rights reserved. | ||
Aiding App™ is licensed under the Elastic License 2.0. For more details, | ||
see <https://github.com/canyongbs/aidingapp/blob/main/LICENSE.> | ||
Notice: | ||
- You may not provide the software to third parties as a hosted or managed | ||
service, where the service provides users with access to any substantial set of | ||
the features or functionality of the software. | ||
- You may not move, change, disable, or circumvent the license key functionality | ||
in the software, and you may not remove or obscure any functionality in the | ||
software that is protected by the license key. | ||
- You may not alter, remove, or obscure any licensing, copyright, or other notices | ||
of the licensor in the software. Any use of the licensor’s trademarks is subject | ||
to applicable law. | ||
- Canyon GBS LLC respects the intellectual property rights of others and expects the | ||
same in return. Canyon GBS™ and Aiding App™ are registered trademarks of | ||
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks | ||
vigorously. | ||
- The software solution, including services, infrastructure, and code, is offered as a | ||
Software as a Service (SaaS) by Canyon GBS LLC. | ||
- Use of this software implies agreement to the license terms and conditions as stated | ||
in the Elastic License 2.0. | ||
For more information or inquiries please visit our website at | ||
<https://www.canyongbs.com> or contact us via email at legal@canyongbs.com. | ||
</COPYRIGHT> | ||
*/ | ||
|
||
namespace AidingApp\ServiceManagement\Rules; | ||
|
||
use Closure; | ||
use Illuminate\Contracts\Validation\ValidationRule; | ||
use Illuminate\Translation\PotentiallyTranslatedString; | ||
use AidingApp\ServiceManagement\Models\ServiceRequestType; | ||
|
||
class ManagedServiceRequestType implements ValidationRule | ||
{ | ||
/** | ||
* Run the validation rule. | ||
* | ||
* @param PotentiallyTranslatedString $fail | ||
*/ | ||
public function validate(string $attribute, mixed $value, Closure $fail): void | ||
{ | ||
if (auth()->user()->hasRole('authorization.super_admin')) { | ||
return; | ||
} | ||
|
||
$team = auth()->user()->teams()->first(); | ||
|
||
$isManager = ServiceRequestType::where('id', $value) | ||
->whereHas('managers', function ($query) use ($team) { | ||
$query->where('teams.id', $team?->getKey()); | ||
}) | ||
->exists(); | ||
|
||
if (! $isManager) { | ||
$fail('You are not authorized to select this service request type.'); | ||
} | ||
} | ||
} |
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.