Add secure team invitation links#4401
Open
shmlkv wants to merge 2 commits into
Open
Conversation
|
@shmlkv is attempting to deploy a commit to the Umami Software Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Greptile SummaryThis PR adds secure team invitation links. The main changes are:
Confidence Score: 4/5The invite feature has contained issues that need fixes before merging.
prisma/migrations/22_add_team_invite/migration.sql, src/app/invite/InvitePage.tsx
|
| Filename | Overview |
|---|---|
| prisma/migrations/22_add_team_invite/migration.sql | Adds the invite table and indexes, but duplicate membership cleanup can preserve stale roles. |
| src/lib/team-invite.ts | Adds invite token creation, hashing, issuance, validation, and transactional redemption. |
| src/queries/prisma/teamInvite.ts | Adds the Prisma invite repository with row locking, inspection, revocation, and consume helpers. |
| src/app/invite/InvitePage.tsx | Adds the public invite page, with stale joined-team state and disabled-password-auth UI issues. |
| src/app/api/auth/login/route.ts | Moves login token creation into a shared auth response helper and adds no-store/password-auth checks. |
| src/app/api/teams/invites/register/route.ts | Adds public invite registration with rate limiting, password-auth checks, and transactional redemption. |
Sequence Diagram
%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant U as Invite recipient
participant UI as Invite page
participant Inspect as Inspect API
participant Auth as Auth API
participant Accept as Accept API
participant DB as Postgres
U->>UI: Open invite link
UI->>Inspect: Inspect token
Inspect->>DB: Read invite metadata
Inspect-->>UI: Team and role
U->>UI: Sign in or register
UI->>Auth: Login or register
Auth-->>UI: Auth response
UI->>Accept: Redeem invite
Accept->>DB: Create membership and consume invite
Accept-->>UI: Joined team
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant U as Invite recipient
participant UI as Invite page
participant Inspect as Inspect API
participant Auth as Auth API
participant Accept as Accept API
participant DB as Postgres
U->>UI: Open invite link
UI->>Inspect: Inspect token
Inspect->>DB: Read invite metadata
Inspect-->>UI: Team and role
U->>UI: Sign in or register
UI->>Auth: Login or register
Auth-->>UI: Auth response
UI->>Accept: Redeem invite
Accept->>DB: Create membership and consume invite
Accept-->>UI: Joined team
Reviews (1): Last reviewed commit: "feat: add team invitation links" | Re-trigger Greptile
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.
Summary
DISABLE_LOGINis configured.Security
Screenshot
Testing
pnpm test— 28 test files, 165 tests passed.pnpm exec tsc --noEmitpnpm build-appNeed help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.