userRole.enum.ts and enforced by middleware in auth.middleware.ts.
Role comparison
The dashboard route splits admin vs user via a role check in
MainRoutes.tsx. Both roles authenticate with the same login flow (email/password + optional MFA).pageAccess
Non-admin users do not see every index on the dashboard. Access is controlled bypageAccess — an array of IndexSetting ObjectId references on the User document.
How it works
Admin auto-grant
Admins are automatically grantedpageAccess to every active index. When a new index setting is created or activated, indexSetting.controller.ts updates all admin users with $addToSet: { pageAccess: _id }.
Regular users must be explicitly assigned indices by an admin.
Authentication middleware
Routes are protected by composable middleware inauth.middleware.ts:
Admin-only routes (user CRUD, index settings CRUD, schedule order cancellation) use
isAdmin. Trading and dashboard APIs typically use isAuth so both roles can operate within their scope.
Single-session JWT
The platform enforces one active session per user. On login, the backend stores the issued JWT in the user’sloginToken field:
isToken middleware compares the Authorization: Bearer … header against the stored loginToken. If they do not match, the request is rejected.
MFA
Users can enable TOTP-based multi-factor authentication viaspeakeasy. When MFA is active, login requires a valid TOTP code in addition to email and password. See MFA.
Related documentation
- Login flow — email/password authentication
- Session management — JWT lifecycle and logout
- Page access — assigning indices to users
- Auth middleware — backend enforcement details