caelum0x ad4e3c8563 fix: make Ritgram repository ownership checks forge-aware
Rithub (Gitea) sign-in users could never manage their own repos because
every ownership gate in repositoryController only checked User.githubUsername.
Add isRepositoryOwner (repositoryController.ts) + getForgeLogin/getAllForgeLogins
(forgeConnectionService.ts) to resolve ownership against the user's login on
the repo's own forge (GitHub or Rithub/Gitea), or an explicit claim.

Also:
- Add the missing GET /api/v1/users/:id/repositories route + controller
  (previously had no backend route at all; profile tab always 404'd).
- Fix computeTrendingForTier's stale TrendingEntry rows: delete by tier
  instead of by (tier, periodStart), since periodStart drifts every run
  and left duplicate rows piling up in the trending list.

Verified locally: tsc --noEmit clean; ran the real backend (port 3001,
real Neon DB), registered a throwaway user, linked a Gitea ForgeConnection
to the real caelum0x Gitea repos, and confirmed a previously-403 AITM
settings endpoint now returns 200 for that Gitea-only user (403 for a
control user with no forge link). Confirmed computeTrendingForTier no
longer accumulates duplicate rows across repeated runs. Test users and
temp verification script removed after.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-11-16 14:57:28 +03:00
..