Skip to content

User invite system: wrong URL (missing /_emdash/ prefix) + no UI to complete registration #67

Closed

Description

@welbinator

Environment

  • EmDash version: 0.0.3
  • @emdash-cms/auth version: 0.0.1
  • Adapter: Node.js + SQLite (Hetzner VPS)

Bug 1: Invite URL missing /_emdash/ prefix → 404

File: packages/auth/src/invite.ts (approx. line 65)

const url = new URL("/api/auth/invite/accept", config.baseUrl);

config.baseUrl is passed in as https://example.com/_emdash (from getSiteBaseUrl()). When constructing new URL("/api/auth/invite/accept", "https://example.com/_emdash"), the leading slash on the path is treated as an absolute path, which replaces the entire path of the base URL — discarding /_emdash.

Resulting URL (wrong):

https://example.com/api/auth/invite/accept?token=...

Expected URL:

https://example.com/_emdash/api/auth/invite/accept?token=...

Since the route is registered at /_emdash/api/auth/invite/accept, clicking the invite link returns a 404.

Suggested fix — use a relative path or string concatenation instead:

const url = new URL(`${config.baseUrl}/api/auth/invite/accept`);

Bug 2: GET /invite/accept returns raw JSON — no UI to complete registration

File: src/astro/routes/api/auth/invite/accept.ts

When the invitee visits the invite link (after fixing Bug 1), the GET handler validates the token and returns raw JSON:

{"success":true,"email":"[email protected]","role":30,"roleName":"AUTHOR"}

There is no redirect to an admin UI page where the user can complete registration. The POST /invite/complete endpoint expects a WebAuthn passkey credential — but there is no frontend page to drive that flow.

Result: The user is never actually created. Checking the Users section in the admin dashboard confirms no new user appears despite the success: true response. The invite flow is effectively non-functional end-to-end.

Expected behavior: GET /invite/accept should redirect to an admin UI page (e.g. /_emdash/admin/invite/accept?token=...) that renders a form for the user to complete registration (set name, register passkey or set password).


Summary

The invite flow has two compounding bugs:

  1. The link given to admins to share points to a 404
  2. Even after manually correcting the URL, visiting it returns JSON with no UI — and no user is actually created in the database

Both issues make the user invite system completely non-functional on the Node.js adapter.

Activity

  1. SrikanthAlva commented on Apr 2, 2026

    @SrikanthAlva

    Hi! I'd like to work on this. I plan to fix both bugs — the invite URL construction (Bug 1) and the GET /invite/accept handler returning raw JSON instead of redirecting (Bug 2). Let me know if there's anything I should be aware of.

  2. added a commit that references this issue on Apr 27, 2026
    721bf8f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions