next-auth icon indicating copy to clipboard operation
next-auth copied to clipboard

Add error for oauth denial

Open cderszteler opened this issue 1 year ago • 2 comments

☕️ Reasoning

Adds another error type to oauth2 abortion. When an oauth2 request is actively cancelled by the user, this error type will be used.

With that, it is possible to identify an cancellation as intended and react properly. This is useful if you have for example only one provider and redirect on /api/auth/signin directly to this provider. That would currently end in an infintie loop, which can be avoid by checking if the user canceled the request intentionally.

🧢 Checklist

  • [x] Documentation
  • [x] Tests
  • [x] Ready to be merged

🎫 Affected issues

Fixes: https://github.com/nextauthjs/next-auth/discussions/3682

📌 Resources

cderszteler avatar Aug 03 '22 12:08 cderszteler

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
next-auth ✅ Ready (Inspect) Visit Preview Aug 15, 2022 at 3:48PM (UTC)

vercel[bot] avatar Aug 03 '22 12:08 vercel[bot]

Hey,

I wasn't quite sure, if this update is what you meant. I added the other oauth2 error responses and tried to sort them by "fault" (developer, user, etc.).

Depending on the fault, the user sees a different message and the error is logged.

Furthermore, I tried to add a bit more documentation, however I don't know if that's what you meant.

cderszteler avatar Aug 04 '22 14:08 cderszteler

Good/bad news, this will be handled in the new @auth/core package: https://github.com/nextauthjs/next-auth/blob/2cbf81544523044596125d2c87175ee4ec61df06/packages/core/src/lib/oauth/callback.ts#L80C7-L87, but not planning to backport it for next-auth at the moment. Thanks for the PR anyway!

balazsorban44 avatar Dec 31 '22 09:12 balazsorban44