如何解决NextAuth 凭据未保存在状态
我将 nextAuth 与我自己的用户数据库 (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)
这似乎是一个巨大的障碍......我目前这样做是为了克服它,我想知道这里的缺点是什么:
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}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。