Reactjs 下一个凭据未保存在状态中
我将Nextuth与我自己的用户数据库(mongoDb)一起使用,我希望用户能够使用他们的凭据登录。问题是我的用户对象没有保持在状态,这似乎是nextAuth的人为了阻止用户名和密码而做出的设计选择,他们说:Reactjs 下一个凭据未保存在状态中,reactjs,next.js,next-auth,Reactjs,Next.js,Next Auth,我将Nextuth与我自己的用户数据库(mongoDb)一起使用,我希望用户能够使用他们的凭据登录。问题是我的用户对象没有保持在状态,这似乎是nextAuth的人为了阻止用户名和密码而做出的设计选择,他们说: If you use a custom credentials provider user accounts will not be persisted in a database by NextAuth.js (even if one is configured) 这似乎是一个巨大的
If you use a custom credentials provider user accounts will not be
persisted in a database by NextAuth.js (even if one is configured)
这似乎是一个巨大的阻碍。。。。我现在这样做是为了克服它,我想知道它的缺点是什么:
async authorize(credentials) {
// check if the user exists in the database
let user = await db.collection('users').findOne({username:credentials.username})
if (user && user.password == credentials.password) {
// return the user object returned from the database
// because next auth will not save this is state
return {name: {user}}
} else {
return {name: null, email: null, image: null}
}
}