js中的护照认证


MongoServerError: E11000 duplicate key error collection: usersDB.users index: username_1 dup key: { username: null }
at E:backend-developmentSecrets - Starting Codenode_modulesmongodbliboperationsinsert.js:53:33
at E:backend-developmentSecrets - Starting Codenode_modulesmongodblibcmapconnection_pool.js:308:25
at E:backend-developmentSecrets - Starting Codenode_modulesmongodblibsdamserver.js:213:17
at handleOperationResult (E:backend-developmentSecrets - Starting Codenode_modulesmongodblibsdamserver.js:329:20)
at Connection.onMessage (E:backend-developmentSecrets - Starting Codenode_modulesmongodblibcmapconnection.js:219:9)
at MessageStream. (E:backend-developmentSecrets - Starting Codenode_modulesmongodblibcmapconnection.js:60:60)
at MessageStream.emit (node:events:527:28)
at processIncomingData (E:backend-developmentSecrets - Starting Codenode_modulesmongodblibcmapmessage_stream.js:132:20)
at MessageStream._write (E:backend-developmentSecrets - Starting Codenode_modulesmongodblibcmapmessage_stream.js:33:9)
at writeOrBuffer (node:internal/streams/writable:389:12) {
index: 0,
code: 11000,
keyPattern: { username: 1 },
keyValue: { username: null },
[Symbol(errorLabels)]: Set(0) {}
}

我无法通过facebook注册后,从google auth注销一次。如何解决这个问题?

您面临这个错误不是因为Passport身份验证,而是因为您使用户名字段唯一,并且您正在尝试使用现有用户名注册新用户。

当你认证你可能注册一个用户,在这种情况下,你必须检查用户名是否已经存在,如果不存在,继续注册你的用户,否则,显示适当的消息或告诉他们选择另一个用户名,因为相同的用户名在你的表/modal中存在。

流程应该是,检查dB中的用户,如果不存在则注册,如果存在则登录。

相关内容

  • 没有找到相关文章

最新更新