Appearance
Onboarding Flow
When the platform starts with an empty database (no users), it must guide the administrator through a setup wizard before the application can be used.
Decision Table
| Scenario | Behavior |
|---|---|
| API unreachable (network error) | Redirect to /login + show error toast |
| API reachable + users exist (setup complete) | Redirect to /login |
| API reachable + no users (setup incomplete) | Redirect to /setup (onboarding wizard) |
How It Works
Setup Status Check
On every navigation, the setupGuard (registered as the first router guard) checks the setup status:
- The guard calls
GET /api/setup/statuson the first navigation - The response is cached in the auth store (
setupStatus) — subsequent navigations skip the API call - If the API is unreachable, the guard fails open (assumes setup is complete) and redirects to
/loginwith an error toast
Route Protection
- Setup incomplete: All routes except
/setupredirect to/setup - Setup complete: Navigating to
/setupredirects to/login - Network error: Non-login routes redirect to
/login
App Initialization (App.vue)
On mount, the app:
- Calls
checkSetupStatus()— fetches and caches the setup status - If setup is complete, calls
refreshSession()to restore the user session - Sets
isInitialized = trueto render the app
This prevents unnecessary session refresh attempts when the database is empty.
Setup Wizard
The wizard at /setup has two steps:
Step 1: Platform Configuration
- Platform name
- Platform description (optional)
- Calls
POST /api/setup/platform
Step 2: SuperAdmin Account
- Email, username, password, first name, last name
- Calls
POST /api/setup/superadmin - Returns an access token for automatic login
Post-Setup
After the superadmin is created:
- The access token is stored in memory
markSetupComplete()updates the cached status- The user profile is fetched
- The app redirects to the dashboard (
/)
What Gets Seeded
During setup, the backend creates:
- Default roles (
SuperAdmin,Admin,Employee,User) - Default permissions (all
entity:actionpairs) - The SuperAdmin user with all permissions
- Password policy with default values
- Platform configuration record
Security Considerations
- The setup endpoints (
/api/setup/platform,/api/setup/superadmin) are only accessible when no users exist - After the first user is created, these endpoints return
409 Conflict - The superadmin creation uses a serializable transaction to prevent race conditions
- Rate limiting is applied to all setup endpoints