Fix tower invitations and add email invites - #52
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved moderate issues remain in invitation ordering, identifier handling, UI refresh, username length, SQL coverage, and route-test coverage.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 4
Open (4)
What changed in this PR
This PR modernizes tower invitations with API/RPC-backed username and email invites, Supabase invite emails, invite-link routing, and profile initialization fixes.
Changes:
- Adds secure invitation lookup and membership helpers.
- Supports existing-user and email invitation flows.
- Updates sharing UI, authentication handling, API contracts, and tests.
| File | Summary and review notes |
|---|---|
clocktower/types/supabase.ts |
Adds invitation RPC types. |
clocktower/tools/actions/fetchSupabaseProfileSA.ts |
Returns newly created profiles. Moderate (2 votes): generated usernames can exceed the 30-character contract. |
clocktower/supabase/migrations/20260919114000_email_tower_invitations.sql |
Adds secure email lookup and membership helpers. Moderate (2 votes): new auth-only paths lack SQL regression coverage. |
clocktower/lib/towers/inviteUserToTower.ts |
Implements username/email invitations. Moderate (3 votes): usernames containing @ are misclassified. Moderate (2 votes): email delivery precedes membership creation. |
clocktower/lib/towers/inviteUserToTower.test.ts |
Tests invitation service behavior. |
clocktower/lib/towers/invite-user-request.ts |
Updates the invitation request contract. |
clocktower/lib/towers/invite-user-request.test.ts |
Tests invitation requests. |
clocktower/lib/supabase/admin.ts |
Adds the server-side admin client. |
clocktower/components/layout/ShareTowerPopover.tsx |
Updates the sharing UI. Moderate (1 vote): email invites do not refresh the displayed membership state. |
clocktower/components/layout/actions/inviteUserToTowerSA.test.ts |
Updates legacy action tests. |
clocktower/components/auth/InviteAuthRedirect.tsx |
Handles invite-link sessions and routing. |
clocktower/app/page.tsx |
Mounts invite-link handling. |
clocktower/app/api/towers/[id]/invitations/route.ts |
Provides the stable invitation endpoint. |
clocktower/app/api/towers/[id]/invitations/route.test.ts |
Tests endpoint behavior. Moderate (1 vote): prior CSRF, validation, ignored-field, and failure-path coverage was removed. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What this fixes
Database
These migrations have already been applied to Supabase project
estelamtbxdegwijmyha:repair_tower_invitationsemail_tower_invitationsrepair_email_invitation_acceptanceThe normal public invitation RPCs are SECURITY INVOKER functions backed by narrowly scoped helpers in the non-exposed
clocktower_privateschema. The email acceptance-repair RPC is callable only byservice_role;anonandauthenticatedhave no execute permission.Deployment
The database changes are backwards-compatible with the previous app code.
The hosted Supabase Invite email template itself is unchanged. Supabase's default invite email works with this flow. Custom wording such as "You're invited to this tower. Click to join." can be configured in Authentication → Email Templates → Invite.
Verification
Final verification on the PR branch:
No test invitation emails were sent to real users during verification.