- Sidebar reorganized: Workspace group (connections, hashtags, labels, API keys, settings) and Account group (settings, usage, billing) - Account group only visible to owner and hidden in self-hosted mode - Onboarding simplified: role -> account (connect socials) -> completed -> redirect to /subscribe. Removed Subscription setup step. - Subscribe page redesigned with 4 plan cards, monthly/yearly toggle, trial info, and per-plan features list - Billing page redesigned following Sendkit layout (sections with sidebar labels) - Processing page uses usePoll with immediate watch for subscription activation - Cancel URL redirects directly to /subscribe - Account settings page with name and billing_email (syncs with Stripe) - Usage page with ring meters for all plan limits - Settings layout tabs only for user pages (profile, password, notifications). Workspace/API keys/billing are standalone pages. - GoogleAuthButton extracted as reusable component - WorkspaceRole TypeScript enum for type-safe role checks in frontend - Trial period changed to 7 days - Fixed onboarding loop when user confirms email - All 1101 tests passing
55 lines
1.6 KiB
PHP
55 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Middleware\App;
|
|
|
|
use App\Enums\User\Setup;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class EnsureUserSetupIsComplete
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param Closure(Request): (Response) $next
|
|
*/
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
$user = $request->user();
|
|
|
|
if (! $user) {
|
|
return $next($request);
|
|
}
|
|
|
|
// If setup is completed, allow through
|
|
if ($user->setup === Setup::Completed) {
|
|
return $next($request);
|
|
}
|
|
|
|
// Map setup status to allowed routes
|
|
$allowedRoutes = match ($user->setup) {
|
|
Setup::Role => ['app.onboarding.role', 'app.onboarding.role.store'],
|
|
Setup::Connections => ['app.onboarding.account', 'app.onboarding.account.store', 'app.social.*'],
|
|
default => ['app.onboarding.role', 'app.onboarding.role.store'],
|
|
};
|
|
|
|
$currentRoute = $request->route()?->getName();
|
|
|
|
// Check if current route is allowed
|
|
foreach ($allowedRoutes as $pattern) {
|
|
if ($currentRoute === $pattern || fnmatch($pattern, $currentRoute ?? '')) {
|
|
return $next($request);
|
|
}
|
|
}
|
|
|
|
// Redirect to appropriate step
|
|
return match ($user->setup) {
|
|
Setup::Role => redirect()->route('app.onboarding.role'),
|
|
Setup::Connections => redirect()->route('app.onboarding.account'),
|
|
default => redirect()->route('app.onboarding.role'),
|
|
};
|
|
}
|
|
}
|