Add profile to `linkAccount` event data
See original GitHub issueDescription 📓
Hello, when linking an OAuth account to a user, I’d like to set User.image
to the profile picture of the newly linked account, if the user does not currently have an image.
Here’s an example of how I’d like to be able to do this in the linkAccount
event:
events: {
async linkAccount({ user, profile }) {
if (!user.image && profile.image) {
await prisma.user.update({
where: { id: user.id },
data: { image: profile.image },
})
}
},
}
This would rely NextAuth.js to send profile
in the data with the linkAccount
event, here.
Could we add this? I tested it out locally (by manually editing my node_modules
), and it worked as expected. Happy to add it in a PR.
(Also, is the linkAccount
event the best place to do this? To me, it feels like an intuitive place to put it, but the documentation for events seem to imply that events should only be used for debugging/audit logs.)
How to reproduce ☕️
See code snippet above.
Contributing 🙌🏽
Yes, I am willing to help implement this feature in a PR
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Thanks y’all! Just opened a PR for it 😃
To me, this is a reasonable suggestion. It would make
linkAccount
andsignIn
API look almost the same.I think this is the intented place for handling side effects like your use case 👍