Repository navigation
Conversation
…om an invite link Admins and facility staff can't self-register (PRD OQ-2) — they join through an invite. Adds /#/invite?token=… (InvitePage + src/features/invite/): validates the token, shows the inviting organisation, role and inviter, and creates the account with the invite's role (never a form field, never in the request payload); an already-signed-in user accepts with one click, and a signed-out existing user goes through /login and straight back to the invite via router state. Clear expired / revoked / already-used / not-found states. The token is read from the URL once and immediately stripped, and nothing is persisted to storage. Built against assumed shapes pending docforum-core#39/DocForum#75 (documented in ARCHITECTURE_ESSENTIALS.md "Known assumptions"); MSW mock handlers with demo tokens included. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@aojomo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This branch has not been deployed
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.
feat(auth): invitation redemption — admin and facility staff signup from an invite link
Closes #81
Admins and facility staff can't self-register (PRD OQ-2) — they join through an invite. This PR adds the invite landing route, the redemption flow, and the tests for it.
Summary
/#/invite?token=…(src/pages/InvitePage.tsx, route inApp.tsx, feature code insrc/features/invite/): validates the token againstGET /auth/invites/:token, then shows the inviting organisation, the role the invite grants, who invited them, and the invited email.status: 'accepted'), and unknown/used-up tokens (404), plus a slow-server hint (Render free-tier cold start) and a retry for transient failures.AcceptInviteInputhas noroleproperty (TypeScript makes it unrepresentable); docforum-core derives the role from the token server-side. A test appends?role=adminto the invite link and asserts neither the shown role nor the accept payload changes.replace), so the credential doesn't linger in the address bar or browser history. Nothing is written to localStorage/sessionStorage (hard rule) — reloading/inviteshows the invalid-link state and the person simply reopens the link from their email.API contract (assumed — doc-update)
docforum-core#39 (admin invites) and docforum-core#75 (facility staff invites) haven't landed, so the contract is assumed and documented in
ARCHITECTURE_ESSENTIALS.md"Known assumptions — Invitation redemption":GET /auth/invites/:token(unauthenticated — the link itself is the credential) →AccountInvite={id, email, role: 'facility'|'admin', organisationName, organisationType?, invitedBy?, status: 'pending'|'accepted'|'revoked'|'expired', invitedAt, expiresAt};404= unknown token.POST /auth/invites/:token/accept(body{email, fullName?, password?}, plusAuthorization: Bearerwhen an existing user accepts) →{user, accessToken}, the same session envelope as signup/login.Mirrored in
src/types/models.ts(AccountInvite/InviteRole/AccountInviteStatus). MSW mock handlers with demo tokens (admin-demo,expired-demo,revoked-demo,used-demo,missing) keepnpm run dev:mockworking end-to-end.Screenshots
Taken against
npm run dev:mock(MSW fake data), same convention as #147 — the invite endpoints don't exist indocforum-coreyet.screenshots/invite-landing-desktop.pngscreenshots/invite-landing-mobile.pngscreenshots/invite-expired-desktop.pngscreenshots/invite-expired-mobile.pngscreenshots/invite-used-desktop.pngscreenshots/invite-not-found-desktop.pngscreenshots/invite-accept-signed-in-desktop.pngscreenshots/invite-accept-signed-in-mobile.pngChecks
Implements the PRD §4 admin/facility onboarding flow via PRD OQ-2 (invite-only accounts).
ROADMAP.mdupdated (item status + changelog line) andARCHITECTURE_ESSENTIALS.md"Known assumptions" updated for the assumed API shape, per the definition of done.🤖 Generated with Codebuff
Co-Authored-By: Codebuff noreply@codebuff.com