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

Update profile image on login #3491

Merged
merged 1 commit into from
Jun 18, 2023
Merged

Update profile image on login #3491

merged 1 commit into from
Jun 18, 2023

Conversation

AbdBarho
Copy link
Collaborator

@AbdBarho AbdBarho commented Jun 18, 2023

Fixes #2196 (not only for discord, but all providers)

Instead of doing the big mess of having to refresh images in the background, we update the images when the user signs in, from the profile we get from the provider.

This has the side effect that if you have 2 different images on 2 different login providers, your image will always change depending on the last provider you logged in with, but I think this is ok.

Also, consolidate all of the updates that are applied to the user to one database call.

@AbdBarho AbdBarho marked this pull request as ready for review June 18, 2023 08:31
@@ -127,60 +126,44 @@ const authOptions: AuthOptions = {
session.user.role = token.role;
session.user.isNew = token.isNew;
session.user.name = token.name;
session.user.image = token.picture;
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can receive image from user property in the callback here

Copy link
Collaborator Author

@AbdBarho AbdBarho Jun 18, 2023

Choose a reason for hiding this comment

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

you mean the user object which is given as a parameter to the session callback?

the user object is only passed if we are using the database strategy, but we are using jwt.

Or did I misunderstand what you say?

Copy link
Collaborator

Choose a reason for hiding this comment

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

the user object is only passed if we are using the database strategy, but we are using jwt.

Hmm I don't see where the docs mention this, the TS signature doesn't mark it as nullable as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

if I console log it is undefined, would be a lot easier if we did not have to pass everything though the token.

@AbdBarho AbdBarho merged commit 8ea3f14 into main Jun 18, 2023
@AbdBarho AbdBarho deleted the simpler-image-update branch June 18, 2023 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debug user discord image not always available.
2 participants