Skip to content

Update profile image on login#3491

Merged
AbdBarho merged 1 commit into
mainfrom
simpler-image-update
Jun 18, 2023
Merged

Update profile image on login#3491
AbdBarho merged 1 commit into
mainfrom
simpler-image-update

Conversation

@AbdBarho

@AbdBarho AbdBarho commented Jun 18, 2023

Copy link
Copy Markdown
Collaborator

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
session.user.role = token.role;
session.user.isNew = token.isNew;
session.user.name = token.name;
session.user.image = token.picture;

Copy link
Copy Markdown
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

@AbdBarho AbdBarho Jun 18, 2023

Copy link
Copy Markdown
Collaborator Author

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
Copy Markdown
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
Copy Markdown
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