question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add profile to `linkAccount` event data

See original GitHub issue

Description 📓

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:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
michaelhayscommented, Mar 23, 2022

Thanks y’all! Just opened a PR for it 😃

3reactions
ThangHuuVucommented, Mar 23, 2022

To me, this is a reasonable suggestion. It would make linkAccount and signIn API look almost the same.

Also, is the linkAccount event the best place to do this?

I think this is the intented place for handling side effects like your use case 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to link Account with Event in a SOQL Query
I would do something like this : List<Account> accounts = new List<Account>(); for(Account acc :[SELECT Id, (SELECT Id FROM Events WHERE ...
Read more >
Account Linking for Custom Skills | Alexa Skills Kit
Start from the Skill Detail Card; Start from a Link Account Card ... Your skill can have requests that do not need personalized...
Read more >
Link/unlink Google Ads and Analytics - Analytics Help
Linking your Google Ads account to your Analytics property lets you see the ... See ad and site performance data in the Google...
Read more >
Account linking quickstart - PlayFab - Microsoft Learn
Demonstrates how to bind an account to multiple devices and login mechanisms.
Read more >
Distributing reader apps with a link to your website - Support
Requesting the External Link Account Entitlement ... Each entitlement has unique requirements for the data that must be entered into your app's Info.plist ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found