Comments (3)
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.
alright now that makes sense, thanks for the clarification!
from next-auth.
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)
- Middleware Route Protection nextjs example result in Middleware relative urls error HOT 1
- Allow installing svelte 5 (pre-releases) as a peer dependency HOT 1
- Allow installing svelte 5 (pre-releases) as a peer dependency HOT 1
- EDGE_FUNCTION_INVOCATION_TIMEOUT when using DrizzleAdapter | timeout Vercel edge functions HOT 10
- Missing: https://authjs.dev/guides/providers/credentials HOT 1
- Cannot leverage platform attribute in SvelteKit during sign-in HOT 5
- Fix typo
- Documentation on Custom Providers HOT 4
- Auth.js Pages Documentation Page link is broken - Shows 404 HOT 3
- GetToken() not working in middleware.ts HOT 1
- Invalid Callback URL "android-app://com.google.android.googlequicksearchbox/" HOT 1
- Invalid Callback URL "android-app://com.google.android.googlequicksearchbox/"
- Middleware breaks when using next-auth with Firestore Adapter HOT 1
- Update Edge Compatibility section for Middleware HOT 2
- URL Redirection Error on Authentication Failure (Middleware file) HOT 1
- URL Redirection Error on Authentication Failure (Middleware file) HOT 4
- Discord Link invalid HOT 1
- Outdated Next-Auth v4 MongoDB adapter which is broken with MongoDB nodejs driver v6+ HOT 1
- Outdated Next-Auth v4 MongoDB adapter which is broken with MongoDB nodejs driver v6+
- Route "[...nextauth]/route.ts" does not match the required types of a Next.js Route. Invalid configuration "GET": HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-auth.