## Summary - consolidate internal platform naming from `Tenant` to `Environment` / `ManagedEnvironment` across models, controllers, services, and Filament resources - rename environment-scoped UI surfaces such as dashboards, chooser flows, navigation, and related widgets to match the updated environment-first domain language - align middleware, onboarding/review lifecycle services, jobs, and route/context controllers with the new environment-scoped architecture ## Validation - not rerun as part of this commit/push/PR request ## Notes - branch is 1 commit ahead of `platform-dev` - main commit: `refactor: consolidate internal tenant model naming` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #355
46 lines
1.0 KiB
PHP
46 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Support\Middleware;
|
|
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Models\User;
|
|
use App\Services\Auth\CapabilityResolver;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class DenyNonMemberTenantAccess
|
|
{
|
|
/**
|
|
* @param Closure(Request): Response $next
|
|
*/
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
$tenant = $request->route()?->parameter('environment') ?? $request->route()?->parameter('tenant');
|
|
|
|
if (! $tenant instanceof ManagedEnvironment) {
|
|
return $next($request);
|
|
}
|
|
|
|
$user = $request->user();
|
|
|
|
if (! $user instanceof User) {
|
|
return $next($request);
|
|
}
|
|
|
|
if (! app(CapabilityResolver::class)->isMember($user, $tenant)) {
|
|
abort(404);
|
|
}
|
|
|
|
if ($tenant->isRemovedFromWorkspace()) {
|
|
abort(404);
|
|
}
|
|
|
|
if ($tenant->workspace?->isClosed()) {
|
|
abort(404);
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|