Skip to content

Log a login link from the development server - #180

Merged
2chanhaeng merged 1 commit into
mainfrom
feat/dev-login-link
Nov 23, 2026
Merged

2chanhaeng merged 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.

@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: dodok8

Merge Risk: Minimal · up to 7d9de

This adds a development-only option that logs a login link after the server starts. No concrete merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: the development server can now log a login link. It matches the summary and objectives, which add a dev-only login link option to the dev task and server. The title i…
Description check Passed The description states the purpose of the change: the mise dev task accepts --login-link=, which logs a login link after the server listens. It explains the empty-value default of owner@example…
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. scripts/dev.mts passes --dev-login-link and `--dev-lo…
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 the loginLink resolution. (b) --dev-login-origin supplies the frontend o…
Full details: Title check

Explanation

The title states the main change: the development server can now log a login link. It matches the summary and objectives, which add a dev-only login link option to the dev task and server. The title is short, specific, and does not use vague terms.

Full details: Description check

Explanation

The description states the purpose of the change: the mise dev task accepts --login-link=<email>, which logs a login link after the server listens. It explains the empty-value default of owner@example.com, the new hidden --dev-login-link option, and the stored challenge. It 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. scripts/dev.mts passes --dev-login-link and --dev-login-origin to drfed-server when usage_login_link is set. In packages/drfed/src/index.ts, runServer calls logLoginLink after the startup steps, inside the same try block, so the link logs 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 defines defaultLoginLinkEmail = "owner@example.com" and uses it when the value is empty. The issue requests no automated test, so no test requirement applies. The changes since the previous review do not alter these paths in a way that invalidates the earlier conclusion. The post-listen ordering was checked in the index.ts diff. The enclosing listen call was not read in full.

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 the 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. (c) packages/models/src/login.ts adds generateLoginChallengeCode. packages/graphql/src/auth/magic-link.ts uses it in loginByEmail, and packages/graphql/src/auth/hash.ts removes the old generateBase36Code. This shared-generator refactor puts the dev link on the same challenge code path as loginByEmail. It supports the feature. (d) scripts/dev.mts introduces frontendOrigin and reuses it for the login origin default and the dev link origin. 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: a3dc9157-9248-4191-a6fd-4c64bd137396
Commits

Reviewing files that changed from the base of the PR and between a33a15a and 7d9ded8.

Files selected for processing: 1

  • mise.toml

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

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The documentation preview for 7d9ded8 is ready.

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
@2chanhaeng
2chanhaeng merged commit c33e119 into main Nov 23, 2026
36 checks passed
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