-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CallbackRouteError on Credentials when following docs #11074
Comments
For me, just returning null from |
i am facing the exact same issue |
I am not sure if its done intentionally but I went through the next-auth code and figured out that, even though CredentialsSignin error is being thrown, it is then passed to CallbackRouteError, which is why we are getting CallbackRouteError. here as you can see, catch recieves CredentialsSignin error. Since it is an instance of Error and not of AuthError, it skips the conditional, then rest is pretty much self explanatory. In order to solve this issue, if its an CredentialsSignin error, then instead of checking error.type === 'CredentialsSignin', what you can do is |
Experiencing the same issue as others: If I return null from authorize, it throws this error. This issue only started happening after upgrading to the latest beta. I went from |
thanks it worked |
When done this way, it will give the same error again if there is a connection problem with the database. |
@ondery what error are you getting? mind sharing the code snippets? |
The same issue with 5.0.0-beta.19 |
This comment has been minimized.
This comment has been minimized.
@bibaswan7 error.cause.err.code === 'credentials' will give true in case of database connection problems too unfortunately. |
@bibaswan7 I came to the same conclusion, but since I'm using typescript, it screams at me saying that property of code does not exist on type Error. Does anyone know a way to do typing properly with this weird wrapping, as well as @ondery mentioned, a way to disambiguate this error further? I looked into the typing issue a bit more and found commit |
I think I have a fix of just signing in and handling an error if the password is incorrect. Instead of using signIn() function from the @/auth.js file we can do somthing like this in the signinForm:
If the signIn() functions throws an error Then it means that The credentials are invalid...
|
Yeah @Ali-Raza764 That's exactly what I do currently, but I just want a bit more fine grain control over the error, and it is supposed to work, but just doesn't. For example, what if my API endpoint became unreachable and just timed out.. It would still say to check the credentials on the client side, even if they are correct. That would lead the user to try a bunch of times and then try to reset the password, which is not something I would want. Instead I want to distinguish whether it's because of the credentials (user does not exist on the token in the Callback). I think this could just be fixed with the typing, as @bibaswan7 said. The issue for the broken types is #11155. The types are broken in #11050 |
Ok I do understand that. So we can wait until the new release makes a fix ? |
This comment has been minimized.
This comment has been minimized.
In case it's helpful, can confirm that Credentials-based error handling broke for me when switching to from Errors previously classified |
I rolled back from 5.0.0-beta.19 to 5.0.0-beta.18 and it worked for me. Clearly its a bug on 5.0.0-beta.19 so until a new update comes I ll stick to the previous version |
Yeah, downgrading fixed the issue for me too |
Exactly same issue as OP, downgrading to beta.18 didn't work
|
use edit: I forgot to add yarn for yarn users. my bad |
So which version of the code is working for you now?? Can you show an example how you got the custom errors? |
I am facing a similar issue with @auth/core:0.31.0 and @auth/sveltekit:1.1.0. The response object for signIn is always returning no error when user submits invalid credentials. |
this fixed it for me, thanks. |
Tried again a week later with the same code and Also don't throw any other errors except so either |
downgrading from "next-auth": "^5.0.0-beta.19" to 18 allows a custom error responses to throw and be handled in the client. Can't understand abstracting this away from the developer 😕, at least default it to off and allow us to specify an process env var to enable throwing custom core authorize errors and any auth life cycle hook. |
thanks that is work well now |
"next": "14.2.4", |
just downgrade to To fix it first remove next-auth from package json then run npm i then install
inside of the login function
i hope this helps |
Was also seeing this issue and thought it was me! Downgrading to 5.0.0-beta.18 resolved the issue for me! Thanks. |
I had the same error in Version of 5.00-beta 18 and 5.0.0-beta 19
Finaly i was able to handle my custom error here and i test it out in both versions.
https://stackoverflow.com/questions/78627862/next-auth-signin-return-errorconfiguration-in-responce-for-invalid-credenti/78673275#78673275
Please let me know if you have any comments.
Thanks and regards
Emran
…________________________________
From: Liam McClelland ***@***.***>
Sent: Wednesday, July 17, 2024 2:52 PM
To: nextauthjs/next-auth ***@***.***>
Cc: Sayed Emran Mehrwarz ***@***.***>; Comment ***@***.***>
Subject: Re: [nextauthjs/next-auth] CallbackRouteError on Credentials when following docs (Issue #11074)
Was also seeing this issue and thought it was me! Downgrading to 5.0.0-beta.18 resolved the issue for me!
Thanks.
—
Reply to this email directly, view it on GitHub<#11074 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AYAR3WFF5WORCXCY52CSUODZM3RRBAVCNFSM6AAAAABIY7UMXGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZUGM4DIMZTHE>.
You are receiving this because you commented.
|
many thanks |
Can you show how you got the errors? |
For anyone coming here, just follow this one, as mentioned by others: |
I've been working with Next auth for about a week now, and at this point, I wonder why people actually even use this library. I mean, I am guessing that everyone starts using it to integrate auth in their apps quickly, and then end up on spending hours working around the countless issues? Next, auth seems to be written by a team that believes their definite opinions on handling auth are the only way to handle it. The library is the exact opposite of "Flexible." I guess it makes sense if you only want to use some Oauth login with 0 interactions with the DB, but for anything else, why on earth do we keep working around their "single opinion auth flow" to be able to implement authentication in our apps? And if only the docs actually mentioned the hundreds of roadblocks they've implemented to allow for custom behavior, but no, absolutely nothing. It's a shame Lucia has been deprecated. I can't wait for someone to release a complete, unopinionated auth lib that is actually built around the idea of a lib, not some single team's opinionated piece of code that seriously lacks documentation. For anyone reading this, if you haven't spend more than a few hours on resolving next auth issues: I'd recommend staying away, and simply build auth from scratch. You'll spend less time implementing a single JWT flow, interactions with your db, and error handling. |
I couldn't agree more! next-auth@5.0.0-beta is a complete waste of time. |
Could not agree more. The only reason I use Next auth is that it provides the Facebook, Google etc authentications. Though, the time I have used solving weird issues and non-flexibility could have been used to write 20 integrations to different providers' services. |
Provider type
Credentials
Environment
Reproduction URL
https://github.com/theswampire/authjs-bug-reproduction
Describe the issue
When using the Credentials Provider, submitting a wrong password throws an CallbackRouteError. I tested it on 5.0.0-beta.18, 17 and 16 too but they throw CredentialsSignIn instead.
I followed the v5 docs for setting up Nextjs and the Credentials Provider step by step thus this should be unexpected behaviour.
This is the
auth.ts
file:The SignIn page looks like this:
I tried to wrap the signIn call in a try-catch like in #11010 but that obviously didn't fix the underlying issue.
According to the documentation, the CallbackRouteError using the Credentials Provider means that either the
authorize
or another callback throws but I didn't overwrite any callbacks nor shouldauthorize
throw anything. Furthermore, if I remember correctly, when settingredirect
to false, theSignInResponse
containedok: true
and a Configuration error which I find odd.How to reproduce
Enter anything but the correct password "password" and then the exception should be thrown.
Using the correct password works just fine.
Expected behavior
Don't throw an exception.
The text was updated successfully, but these errors were encountered: