Skip to content

Log a login link from the development server - #180

Open
2chanhaeng wants to merge 1 commit into
mainfrom
feat/dev-login-link
Open

2chanhaeng wants to merge 1 commit into
mainfrom
feat/dev-login-link

Conversation

@2chanhaeng

Copy link
Copy Markdown
Member

Closes #179.

mise run dev --login-link=<email> logs a login link for the account once the server listens. --login-link= means owner@example.com, since mise task flags cannot take an optional value. The task passes the address to a new hidden --dev-login-link option of drfed-server, which stores a challenge as loginByEmail does.

AI disclosure: written with Claude Code (claude-opus-5-5), verified against a PGlite server. The user tested themselves and verified.

mise run dev --login-link=<email> logs, right after the server starts
listening, a link that logs in as the account with that email address,
so that a seeded account can be used without reading login mail.  An
empty value, --login-link=, means owner@example.com, since mise task
flags cannot take an optional value.

The task passes the address to the new hidden --dev-login-link option
of drfed-server, together with the origin of the frontend development
server through the new hidden --dev-login-origin option, which must be
one of the login origins.  When the server serves the frontend, the
origin defaults to the public web origin; otherwise it is required.
The server stores a login challenge for the account and logs the
frontend's confirmation link.  An address no account has is only
warned about.  The challenge is the one loginByEmail stores, so it is
single-use and expires after 15 minutes; the challenge code generator
moves to @drfed/models/login as generateLoginChallengeCode() so that
both share it.

AI assistance: the maintainer asked Claude Code for a dev task option
that logs a login link after startup.  Claude Code designed the hidden
server options, wrote the code, and moved the code generator.  The
maintainer found that the first design, which took the first login
origin, pointed to the GraphQL server.  The build, checks, and
affected tests were run, and the logged link was completed through
completeLoginChallenge against a PGlite server.

Assisted-by: Claude Code:claude-opus-5-5
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The development task accepts a login-link email and passes it to the server. After startup, the server creates a challenge for a matching account and logs its confirmation URL.

Changes: Development login links

Layer / File(s) Summary
Shared login challenge code generation
packages/models/src/login.ts, packages/graphql/src/auth/hash.ts, packages/graphql/src/auth/magic-link.ts
The models package adds generateLoginChallengeCode(). GraphQL email login uses it instead of the removed generateBase36Code() helper.
Development login-link options
mise.toml, scripts/dev.mts, packages/drfed/src/parser.ts
The dev task adds --login-link. The script passes the supplied email, or owner@example.com when the value is empty, and the frontend origin to the server. The parser resolves the options and checks that the origin is configured as a login origin.
Challenge creation and startup logging
packages/drfed/src/dev-login.ts, packages/drfed/src/index.ts
After startup, the server creates a login challenge for a matching account and logs the confirmation URL. If no account matches, it logs a warning.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature · Severity of issue fixed: Low

Sequence Diagram(s)

sequenceDiagram
  participant DevTask
  participant ServerParser
  participant RunServer
  participant OperationRegistry
  participant CreateLoginLink
  participant Database
  participant Logger
  DevTask->>ServerParser: Pass login-link email and origin
  ServerParser->>RunServer: Return resolved loginLink options
  RunServer->>OperationRegistry: Run logLoginLink after startup
  OperationRegistry->>CreateLoginLink: Request link for email and origin
  CreateLoginLink->>Database: Look up account and store challenge
  CreateLoginLink-->>OperationRegistry: Return confirmation URL
  OperationRegistry->>Logger: Log email and URL
Loading

Suggested reviewers: dahlia

Merge Risk: Minimal · up to a33a1

This adds an opt-in development login-link option with no identified production-facing risk. It looks safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "Log a login link from the development server" matches the main change. The PR adds a mise run dev --login-link=<email> option that logs a login link for an account after the development s…
Description check Passed The description states the purpose of the change. It covers the mise run dev --login-link=<email> flag, the owner@example.com default for an empty value, and the hidden --dev-login-link option p…
Linked Issues check Passed Issue #179 has one direct coding requirement set. (1) mise run dev --login-link=<email> logs a login link after the server starts listening. The scripts/dev.mts change passes --dev-login-link to…
Out of Scope Changes check Passed The changes support the requested feature. (a) packages/drfed/src/parser.ts adds the hidden --dev-login-link option and loginLink resolution. (b) --dev-login-origin supplies the frontend origi…
Full details: Title check

Explanation

The title "Log a login link from the development server" matches the main change. The PR adds a mise run dev --login-link=&lt;email&gt; option that logs a login link for an account after the development server starts listening. The title is short, specific, and does not list files.

Full details: Description check

Explanation

The description states the purpose of the change. It covers the mise run dev --login-link=&lt;email&gt; flag, the owner@example.com default for an empty value, and the hidden --dev-login-link option passed to drfed-server. It also references issue #179. This relates directly to the changeset.

Full details: Linked Issues check

Explanation

Issue #179 has one direct coding requirement set. (1) mise run dev --login-link=&lt;email&gt; logs a login link after the server starts listening. The scripts/dev.mts change passes --dev-login-link to drfed-server when usage_login_link is set. The packages/drfed/src/index.ts change logs the link in runServer after startup. (2) The link logs in as the given account. createLoginLink in packages/drfed/src/dev-login.ts looks up the account, stores a login challenge, and returns a confirmation URL. (3) An empty value selects owner@example.com. scripts/dev.mts uses defaultLoginLinkEmail when the value is empty. The change set does not add a specific automated test. The issue does not request one, so no test requirement applies. The author reports manual verification against PGlite. This verification is not part of the coding requirements. Evidence comes from the whole-PR summary. I did not inspect the source hunks directly, so the post-listen ordering rests on the summary text.

Full details: Out of Scope Changes check

Explanation

The changes support the requested feature. (a) packages/drfed/src/parser.ts adds the hidden --dev-login-link option and loginLink resolution. (b) --dev-login-origin supplies the frontend origin needed to build the confirmation link. The issue does not name this option, but the link cannot be built without an origin. The option defaults to the public web origin when the server serves the frontend. (c) packages/models/src/login.ts adds generateLoginChallengeCode. packages/graphql/src/auth/magic-link.ts uses it in loginByEmail. packages/graphql/src/auth/hash.ts removes the old generateBase36Code. This is a shared-generator refactor so that the dev link uses the same challenge code path as loginByEmail. It is a supporting change, not unrelated work. (d) scripts/dev.mts renames the login origin variable to frontendOrigin and reuses it. This supports the same flow. No change appears unrelated to #179.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: afe66974-ec54-4e0e-919b-a6871484d940
Commits

Reviewing files that changed from the base of the PR and between 5a44ee0 and a33a15a.

Files selected for processing: 8

  • mise.toml
  • packages/drfed/src/dev-login.ts
  • packages/drfed/src/index.ts
  • packages/drfed/src/parser.ts
  • packages/graphql/src/auth/hash.ts
  • packages/graphql/src/auth/magic-link.ts
  • packages/models/src/login.ts
  • scripts/dev.mts
Files with no reviewable changes: 1

  • packages/graphql/src/auth/hash.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions

Copy link
Copy Markdown

The documentation preview for a33a15a is ready.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Log a login link from the development server

2 participants