Login page silently ignores sign-in errors (e.g. ?error=OAuthCallback)

オープン 初心者向け
#524 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
nextjs, react, typescript

調査の方向性

src/app/auth/login/page.tsx から始めてください。これはセッションを読むだけで searchParams.error は決して読みません。そして "Access denied" をハードコードしている src/app/auth/error/page.tsx のアプローチを踏襲してください。各 NextAuth コード(OAuthSignin、OAuthCallback、Callback、OAuthAccountNotLinked、SessionRequired、Default)を汎用フォールバック付きの短いメッセージにマッピングし、既存の src/app/components/flash/ErrorFlash.tsx を通してログインカードの上にレンダリングしてください。/auth/login?error=OAuthCallback にアクセスしたときに固有のメッセージが表示され、未知のコードが優雅にフォールバックすれば完了です。再現するには GitHub を経由せず、それらの URL を直接読み込んでください。

索引モデルが issue の本文から書いたものです。

説明

bug
Describe the bug

When sign-in fails during the OAuth callback, NextAuth redirects /auth/login?error=<code>, but the login page ignores the error query param and renders the normal "Sign in with GitHub" card. The user ends up back where they started with no indication anything went wrong; the only signal is an Auth error line in the server logs.

NextAuth sends these errors to the sign-in page rather than /auth/error: OAuthSignin, OAuthCallback, OAuthCreateAccount, Callback, OAuthAccountNotLinked, SessionRequired, and Default.

To Reproduce
  1. Set NEXTAUTH_URL to a URL other than the one you browse from (e.g. a tunnel URL, while opening http://localhost:3000)
  2. Click Sign in with GitHub and authorize
  3. The server logs OAUTH_CALLBACK_ERROR … State cookie was missing
  4. The browser lands on /auth/login?error=OAuthCallback showing the normal login card, with no error
Expected behavior

The login page shows an error message (e.g. an ErrorFlash above the login card) when error is present, with a short user-facing message per error code and a generic fallback, so users know to retry or contact an admin.

Screenshots

No response

Additional context
  • src/app/auth/login/page.tsx reads the session but never reads searchParams.error
  • src/app/auth/error/page.tsx has the same problem in the other direction: it always shows "Access denied", whatever the error code
  • The existing ErrorFlash component (src/app/components/flash/ErrorFlash.tsx) could display the message
  • Found while testing #521 over a tunnel; related to #522
主要言語
TypeScript
スター
203
フォーク
42
平均マージ
1時間 15分
マージ済み PR(30日)
8

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github-community-projects/private-mirrors のほかの issue

github-community-projects/private-mirrors の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。