Skip to content
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

create backend user when generate jwt #2702

Merged
merged 5 commits into from
Apr 19, 2023
Merged

Conversation

notmd
Copy link
Collaborator

@notmd notmd commented Apr 18, 2023

Avoid flooding the backend log with user not found error

website/src/pages/api/auth/[...nextauth].ts Outdated Show resolved Hide resolved
}

// TODO avoid duplicate logic with the signIn event
if (frontendUser.isNew && !frontendUser.name) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already create a username in line 143?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to ensure everything still works, since we have no test for this...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I still don't see which edge case is being caught here, or why are we checking for the name in line 140? we had the same sign up process for ever, did anything regarding the sign up requirement change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how next auth work internally, but it seem the jwt callback is called before the signIn event, so in that case the name is not available yet, but the backend requires a name so I have to assign it first. The check !user.name on line 140 is to make sure we don't assign the name again

Copy link
Collaborator

@AbdBarho AbdBarho Apr 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I see, can you please comment that in the code, so we know why we did this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@AbdBarho AbdBarho merged commit b4fea53 into main Apr 19, 2023
@AbdBarho AbdBarho deleted the avoid_user_not_found_log branch April 19, 2023 16:25
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.

2 participants