Skip to content

feat: domain provider role - #47

Merged
andrewstech merged 1 commit into
mainfrom
feature/domain-provider-role
Oct 23, 2026
Merged

andrewstech merged 1 commit into
mainfrom
feature/domain-provider-role

Conversation

@christopher-od

Copy link
Copy Markdown
Contributor

Domain Provider Role

Adds a new domain_provider role for users who donate a domain for use on the platform.

How it works

Role assignment (admin-only):

  • Admin goes to Admin → Users, finds a user, and clicks "Domain Provider" — this grants the domain_provider role
  • Demoting a domain_provider back to user is also supported via the existing "Demote" button
  • Once a user has the role, the admin can go to Admin → Root Domains, click "Assign" on any domain, and select the provider from a list

Domain provider experience:

  • A "Domain Provider" section appears in the sidebar with a "My Donated Domains" link
  • The /domain-provider-dashboard page shows real-time stats: active subdomains, pending requests, DNS record count, new requests in the past 7 days — broken down per domain
  • Sensitive infrastructure fields (zone_id, nameservers, reserved_names, notes) remain redacted; stat fields (record_count, last_synced) are visible

Changes

Backend

  • schema.sql: domain_provider added to role CHECK constraint with idempotent migration block for existing databases
  • server/functions/adminAssignDomainProvider.js: assigns/removes provider_user_id/provider_user_email/provider_assigned_at on Domain entity; validates the target user has domain_provider role before linking; writes AuditLog entries for both assign and unassign
  • server/domain-provider-routes.js: GET /api/domain-provider/stats and GET /api/domain-provider/domains — scoped to the authenticated provider, admins can query any provider via ?user_id=
  • server/entity-routes.js: domain providers see record_count and last_synced for their own domain; zone_id and other infra fields still redacted
  • server/function-runner.js: registers adminAssignDomainProvider
  • server/index.js: registers domain provider routes

Frontend

  • src/pages/DomainProviderDashboard.jsx: new page with stat cards (totals) and per-domain breakdown cards
  • src/pages/AdminUsers.jsx: domain_provider badge (emerald), "Domain Provider" action button for plain users, demote path, Domain Providers count stat
  • src/pages/AdminDomains.jsx: "Assign/Provider" button per domain row opens modal showing current provider + list of domain_provider users to assign; remove provider button
  • src/api/rootminsterClient.js: domainProvider.stats() and domainProvider.domains()
  • src/App.jsx: /domain-provider-dashboard route protected by domain_provider|admin
  • src/components/Layout.jsx: Domain Provider sidebar section and command palette entry

Validation

  • ESLint: clean
  • Tests: 309/309 pass
  • Build: clean, 0 source maps in dist

- Add 'domain_provider' to users role CHECK constraint with migration for
  existing databases
- New adminAssignDomainProvider function: admin-only, assigns or removes a
  domain provider by linking provider_user_id/email on Domain entity; enforces
  that the target user already has the domain_provider role before assignment
- New /api/domain-provider/stats and /api/domain-provider/domains routes:
  returns per-domain and total stats (active subdomains, pending requests,
  DNS records, new requests in 7 days) scoped to the authenticated provider;
  admins can query any provider via ?user_id=
- entity-routes: domain providers see record_count and last_synced for their
  assigned domains (zone_id, nameservers, notes still redacted)
- rootminsterClient: domainProvider.stats() and domainProvider.domains() API
- DomainProviderDashboard page: stat cards, per-domain breakdown, refresh
- AdminUsers: domain_provider badge (emerald), 'Domain Provider' action button
  for user-role accounts, demote path, Domain Providers count in stats bar
- AdminDomains: 'Assign/Provider' button per domain opens a modal that lists
  domain_provider users and shows/removes the current assignment
- App.jsx: /domain-provider-dashboard route protected by domain_provider|admin
- Layout.jsx: 'Domain Provider' sidebar section and command palette entry

Validated: eslint clean, 309/309 tests pass, production build emits 0 source maps
@andrewstech
andrewstech merged commit 85129ae into main Oct 23, 2026
2 checks passed
@andrewstech
andrewstech deleted the feature/domain-provider-role branch October 23, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant