singleloginsystem/app/Services/Keka/KekaAccessGuard.php
= feaa8b6c93 Feat: Add modular URL app creation with role-based access and Microsoft integration support
- Introduced `StoreURLAppForm` and `StoreURLAppData` for form handling and data transformation.
- Added `UrlAppService` to streamline URL app creation with settings like `accessUrl` and `isConnectedToMicrosoft`.
- Enhanced user access controls with role-based permissions using `UserAccessTypeEnum`.
- Updated UI for URL app creation with support for logos and dynamic role selection.
- Implemented feature tests to validate URL app creation and access URL formatting.
2026-06-22 07:21:26 +00:00

38 lines
833 B
PHP

<?php
declare(strict_types=1);
namespace App\Services\Keka;
use App\Models\User;
use App\Services\UserAppAccessService;
class KekaAccessGuard
{
private const PROVIDER_SLUG = 'keka-hr';
public function __construct(
private readonly UserAppAccessService $userAppAccessService,
) {}
public function authorize(): User
{
$user = auth()->user();
if (! $user) {
abort(403, 'Unauthorized');
}
$activeServices = $this->userAppAccessService->getActiveServices($user);
$hasAccess = $activeServices->contains(
fn ($service) => self::PROVIDER_SLUG === $service->providerSlug
);
if (! $hasAccess) {
abort(403, 'You do not have permission to access the required application.');
}
return $user;
}
}