Replies: 2 comments 5 replies
-
The behavior you are describing is very odd. I assume that you are using a database, not a session cookie, right? If I'm not mistaken, we use the user ID to identify the user, in github's case, the default is: next-auth/src/providers/github.js Line 13 in 073da60 sharing some code would help to figure out your problem though. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the speedy feedback:) I was not sure where to begin when debugging this, hence the vagueness. I would say i'm running a pretty basic setup, using // api/auth/[nextauth].js
export default NextAuth({
providers: [
Providers.Facebook({
clientId: process.env.FACEBOOK_ID,
clientSecret: process.env.FACEBOOK_SECRET
}),
Providers.Google({
clientId: process.env.GOOGLE_ID,
clientSecret: process.env.GOOGLE_SECRET
}),
Providers.GitHub({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET,
}),
],
adapter: Adapters.TypeORM.Adapter(
process.env.DATABASE_URL,
{
models
}
),
database: process.env.DATABASE_URL,
secret: process.env.SECRET,
session: { },
jwt: {
secret: 'secret',
},
pages: {
signIn: '/login', // Displays signin buttons
},
callbacks: {
async session(session, user) {
return {
...session,
user: {
...session.user,
...user
}
}
},
},
debug: false,
}) where import Adapters from "next-auth/adapters"
class User extends Adapters.TypeORM.Models.User.model {
constructor(name, email, image, emailVerified) {
super(name, email, image, emailVerified)
}
}
const UserSchema = {
name: "User",
target: User,
columns: {
...Adapters.TypeORM.Models.User.schema.columns,
isOnboarded: {
type: "boolean",
nullable: true,
},
email: {
type: "string",
nullable: true
},
username: {
type: "string",
nullable: false
}
},
}
export default {
User: {
model: User,
schema: UserSchema
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When using
next-auth
(locally, not sure if that matters?) I've noticed that it will often, but not always, create a new user instead of reusing my previous one when logging back in. This happens when using the same auth provider with the same credentials. This seems to happen mostly with GitHub though I'm sure I've experienced it with other providers as well.What are the variables involved when
next-auth
decides if a user already exists? Is there anything special going on when running locally? Cannext-auth
not guarantee the same user when logging back in with the same credentials and provider?Beta Was this translation helpful? Give feedback.
All reactions