Skip to content

refactor: replace inline role checks in trust router with proper tRPC procedures #381

Description

@coderabbitai

All four endpoints in the trust router use manual hasRolePermission checks inside the handler instead of the dedicated permission-procedure pattern used elsewhere.

File: src/server/api/routers/trust.ts

Endpoint Line
getTrustLogs 18
getTrustStats 82
runMonthlyActiveBonus 125
adjustTrustScore 137

Also, getTrustLogs contains inline query logic that should be abstracted into a repository or service (line 24).

Action required:

  • Switch each procedure from protectedProcedure + inline role check to the appropriate permission procedure (e.g., superAdminProcedure).
  • Extract the getTrustLogs query logic into a TrustRepository or TrustService.
  • Verify the UI access checks still match after the refactor.

Requested by @Producdevity — related to PR #375

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions