mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Fix findOneAnd* usages
findOneAnd* now returns either a document or null rather than a result set (unless the result set is requested explicitly). See https://www.mongodb.com/blog/post/behavioral-changes-find-one-family-apis-node-js-driver-6-0-0. GitOrigin-RevId: 93dc64cbcc663217f914cf9e9821e2b9642154db
This commit is contained in:
@@ -7,7 +7,7 @@ const { callbackify } = require('util')
|
||||
const ONE_HOUR_IN_S = 60 * 60
|
||||
|
||||
async function peekValueFromToken(use, token) {
|
||||
const result = await db.tokens.findOneAndUpdate(
|
||||
const tokenDoc = await db.tokens.findOneAndUpdate(
|
||||
{
|
||||
use,
|
||||
token,
|
||||
@@ -22,8 +22,6 @@ async function peekValueFromToken(use, token) {
|
||||
returnDocument: 'after',
|
||||
}
|
||||
)
|
||||
|
||||
const tokenDoc = result.value
|
||||
if (!tokenDoc) {
|
||||
throw new Errors.NotFoundError('no token found')
|
||||
}
|
||||
@@ -82,11 +80,10 @@ const OneTimeTokenHandler = {
|
||||
usedAt: now,
|
||||
},
|
||||
},
|
||||
function (error, result) {
|
||||
function (error, token) {
|
||||
if (error) {
|
||||
return callback(error)
|
||||
}
|
||||
const token = result.value
|
||||
if (!token) {
|
||||
return callback(new Errors.NotFoundError('no token found'))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user