Skip to content

Refactor data access to enforce strict guild-scoped multi-tenancy across members, passes, and activity #298

Description

@Lakes41

Difficulty: Advanced
Type: refactor

Background
GuildPass manages multiple guilds/communities, each with their own members, passes, and activity, per the feature list and /guilds route — implying the app is meant to be multi-tenant at the guild level.

Problem
It's not evident from the project structure that member, pass, and activity queries are consistently scoped by guildId; without enforced scoping at the data-access layer, it would be easy for a future real-backend integration to leak one guild's members/passes/activity into another guild's views.

Expected outcome
Every data query for members, passes, and activity requires an explicit guildId and is enforced at a single choke point (not just optionally passed by UI code), so cross-guild data leakage is structurally prevented.

Suggested implementation

  • Introduce a GuildScopedContext (or similar) that wraps all repository/query calls with a mandatory guildId.
  • Update apps/dashboard/lib/mock-data.ts accessors to require guildId as a parameter, throwing/erroring if omitted, rather than defaulting to "all guilds."
  • Add a currently-selected-guild concept to the dashboard (e.g., a guild switcher in the nav) that supplies guildId to all pages via context/route params.
  • Add tests asserting that querying members/passes/activity without a guild context is impossible or clearly rejected.

Acceptance criteria

  • All member/pass/activity queries require a guildId
  • A guild switcher exists in the UI and drives which guild's data is shown
  • Tests confirm scoping cannot be bypassed
  • No existing single-guild functionality regresses

Likely affected files/directories

  • apps/dashboard/lib/mock-data.ts
  • apps/dashboard/app/**
  • apps/dashboard/components/ (guild switcher)
  • packages/integration-client/

Metadata

Metadata

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesOfficial Campaign | FWC26Official FWC26 campaign issue — eligible for campaign scoring and rewardsadvancedAdvanced difficulty tasks requiring significant domain knowledge and implementation effortrefactorCode restructuring without changing external behavior or APIsecuritySecurity-related fix, hardening, audit, or vulnerability remediation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions