-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
#224: display OAuthAccountNotLinked error message + other errors messages #542
Conversation
2e70366
to
ce72a93
Compare
ce72a93
to
b0952bc
Compare
As a sidenote, I've ran the pre-commit's and everything is passing but it's not showing it as having been done on the pull request? |
As I understand, running pre-commit locally is a way of testing your changes against different linters and format fixers. If it passed all is good. |
Ahhh I thought it might have something to do with that, perfect, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I checked how NextAuth does it https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/core/pages/signin.tsx. They seem to pass the error in props somehow. I didn't want to add too much code or change the overall structure too much so I just added a useEffect to check whether the router contains an error. If it does, use a type guard to check if it's a string or an array, and handle them appropriately. I don't think there are cases when you'll get two errors at once, so it's mainly to stop TypeScript errors. I also added all the other error code from the above NextAuth page mentioned, so if other errors pop up they should be correctly displayed to the user. I also changed the error message for the OAuthAccountNotLinked as it didnt' seem to correctly reflect what we'd want the user to do, which is to login with the account they initially logged in with. I added the error message below the terms and conditions, I hope that's alright, obviously it can easily be moved elsewhere. I'm not sure whether you want the SignInErrorTypes and the errors object moved to a separate location? Other than this, any additional thoughts or does this satisfy the requirements?