feat: L'Ami Fiduciaire V1.0.0 — full codebase with Story 0.1 complete
Initial commit of the L'Ami Fiduciaire SaaS platform built on Laravel 12, Vue 3, Inertia.js 2, and Tailwind CSS 4. Story 0.1 (rename folders to declarations in database) is implemented and code-reviewed: migration, rollback, and 6 Pest tests all passing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
37
app/Http/Middleware/EnsureUserHasWorkspace.php
Normal file
37
app/Http/Middleware/EnsureUserHasWorkspace.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class EnsureUserHasWorkspace
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$workspaceId = $request->session()->get('current_workspace_id');
|
||||
|
||||
if (! $workspaceId) {
|
||||
return redirect()->route('dashboard')
|
||||
->with('error', __('Please select a workspace first.'));
|
||||
}
|
||||
|
||||
$user = $request->user();
|
||||
$hasAccess = $user->workspaces()->where('workspaces.id', $workspaceId)->exists();
|
||||
|
||||
if (! $hasAccess) {
|
||||
$request->session()->forget('current_workspace_id');
|
||||
|
||||
return redirect()->route('dashboard')
|
||||
->with('error', __('You do not have access to this workspace.'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user