-
Notifications
You must be signed in to change notification settings - Fork 63
add multi-tenancy #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add multi-tenancy #413
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||
User description
User description
Added multi-tenant UX support to BotSharp-UI. When multi-tenancy is enabled, the login flow loads a selectable tenant list from the BotSharp backend and sends the selected tenant id via
__tenantrequest header. After login, the selected tenant name is displayed in the top-right user area to make the active tenant context explicit.PR Type
Enhancement, UI
Description
Login UX
GET /tenants/options__tenantheaderPost-login UX
Backward compatibility
/tenants/optionsreturns empty array and UI falls back to original single-tenant login without tenant selectorBackend dependency
Tenant options endpoint
GET /tenants/options[{ tenantId: string, name: string }]Tenant header
__tenant: <tenantId>Flow Walkthrough
sequenceDiagram participant UI as BotSharp-UI participant API as BotSharp API UI->>API: GET /tenants/options API-->>UI: [{tenantId, name}] or [] alt multi-tenant enabled (non-empty) UI->>UI: user selects tenant UI->>API: POST /auth/login with header __tenant: <tenantId> API-->>UI: token / session UI->>UI: persist token + tenantName UI->>API: subsequent API calls with header __tenant: <tenantId> UI->>UI: show tenantName in top-right header else disabled / empty list UI->>API: POST /auth/login (original payload) API-->>UI: token / session endTesting
Multi-tenant enabled
__tenantheaderMulti-tenant disabled
Edge cases
/tenants/optionsreturns empty: treat as single-tenant/tenants/optionsfails: fallback behavior matches existing UI error handlingPR Type
Enhancement
Description
Add multi-tenant support to login flow with tenant selector
Persist tenant ID/name in session storage and display in header
Include tenant ID in all API requests via
__tenantheaderGracefully handle single-tenant and multi-tenant scenarios
Diagram Walkthrough
File Walkthrough
+page.svelte
Add tenant selector and multi-tenant login flowsrc/routes/(authentication)/login/+page.svelte
getTenantOptionsfrom auth service and tenant store helpersavailable
enabled
getToken()and persist tenant name aftersuccessful login
Header.svelte
Display current tenant name in headersrc/routes/VerticalLayout/Header.svelte
getTenantNamefrom store helperstenantChangedcustom event to update displayed tenant namedropdowns
http.js
Include tenant ID in all HTTP requestssrc/lib/helpers/http.js
getTenantIdfrom store helpers__tenantheader to all axios requests when tenant ID is availableauthentication
store.js
Add tenant state management functionssrc/lib/helpers/store.js
tenantKeyandtenantNameKeyconstants for session storagegetTenantId(),setTenantId(),clearTenantId()functionsgetTenantName(),setTenantName(),clearTenantName()functions
notifyTenantChanged()to dispatch custom event for tenant changesresetStorage()to clear tenant data when resetting user sessionauth-service.js
Add tenant parameter to auth functionssrc/lib/services/auth-service.js
getToken()to accepttenantIdparameter and include in authheaders
renewToken()to include__tenantheader when tenant ID existsgetTenantOptions()function to fetch available tenants frombackend
api-endpoints.js
Add tenant options API endpointsrc/lib/services/api-endpoints.js
userTenantsUrlendpoint constant pointing to/tenants/options