Giter Club home page Giter Club logo

Comments (3)

iaincollins avatar iaincollins commented on June 3, 2024

Hi there,

You can actually return any properties you like in getProfile() in next-auth.providers.js.

The reason each provider has this function is that the properties are just different for each provider as annoyingly they all use different names for properties rather than using a standard format for a user object, which is why it doesn't save all properties automatically.

In next-auth.functions.js you would need to make sure you use this field in update() and insert() functions and return it from the deseralize() function.

This is quite fiddly and not easy to understand and I'd like to improve this so that the configuration is much simpler in future but I haven't found the time to get around to that recently.

from next-auth.

pantchox avatar pantchox commented on June 3, 2024

alright now that makes sense, thanks for the clarification!

from next-auth.

stelian87 avatar stelian87 commented on June 3, 2024

Hello,
regarding this question i have managed it on my own(sadly before reading this issue):

insert: (user, oAuthProfile) => {
return new Promise((resolve, reject) => {
if (!user.photo && oAuthProfile.photos)
user.photo = oAuthProfile.photos[0].value;
if (!user.emailVerified && oAuthProfile.emails)
user.emailVerified = oAuthProfile.emails[0].verified;

      usersCollection.insert(user, (err, response) => {
        if (err) return reject(err);

        // Mongo Client automatically adds an id to an inserted object, but
        // if using a work-a-like we may need to add it from the response.
        if (!user._id && response._id) user._id = response._id;

        return resolve(user);
      });
    });
  }

....

i have a question for @iaincollins if i may.
What is the best approach for getting additional info from a different source? let's say a web api and adding to the user prop.
Scenario: based on email i want to send a request to a web api and return the role, and pass it to the user in the insert.

from next-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.