Deploy Ladill Care / deploy (push) Successful in 36s
Resolve staff memberships by invite/demo email as well as public_id so nurses stay on their employer org; block staff from owner onboarding; keep Documents viewable with module access while upload stays manage-gated. Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1021 B
PHP
39 lines
1021 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Services\Care\OrganizationResolver;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class EnsureOrganizationSetup
|
|
{
|
|
public function __construct(
|
|
protected OrganizationResolver $organizations,
|
|
) {}
|
|
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
$user = $request->user();
|
|
if (! $user) {
|
|
return $next($request);
|
|
}
|
|
|
|
if ($request->routeIs('care.onboarding*')) {
|
|
return $next($request);
|
|
}
|
|
|
|
if (! $this->organizations->isOnboarded($user)) {
|
|
// Staff already attached to a tenant must not see owner onboarding.
|
|
if ($this->organizations->membershipFor($user)) {
|
|
abort(403, 'Your facility setup is incomplete. Ask an administrator to finish onboarding.');
|
|
}
|
|
|
|
return redirect()->route('care.onboarding.show');
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|