Replies: 1 comment
-
If you're still looking for an answer, I let next-auth handle the login/signup as directed. Then, instead of following the guide to create a custom user model/adapter I create the model and connected to mongoose as suggested by the next with mongoose example. import mongoose from 'mongoose';
const UserSchema = new mongoose.Schema(
{
// make sure to have the name, email, image, and timestamps
name: {
type: String,
},
email: {
type: String,
},
image: {
type: String,
},
// custom fields go here
groups: [
{
type: mongoose.Schema.Types.ObjectId,
ref: 'groups',
},
],
ownedGroups: [
{
type: mongoose.Schema.Types.ObjectId,
ref: 'groups',
},
],
},
{ timestamps: true }
);
export default mongoose.models.User || mongoose.model('User', UserSchema); let me know if this helps |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm new to programming so please forgive me for asking a basic question. I'm trying to extend the User model by adding a 'role' field but can't figure out how to do that. I've read the documentation https://next-auth.js.org/schemas/adapters but I dont know if its possible to use TypeORM for my problem? I think I would need to create a custom adapter am i right? Can someone point me in the right direction please
Beta Was this translation helpful? Give feedback.
All reactions