This commit is contained in:
undefined committed 2020-06-30 23:03:18 +08:00
1 parent 0de7cd7b59
commit 7d7b12392f
18 files changed
+90 -47

No files matched your search

+2 -2
View File
@@ -37,9 +37,9 @@ async function add(tokenType, expireSeconds, data) {
* @param {number} tokenType type of the token.
* @returns {Promise<object>} The token document, or null.
*/
async function get(tokenId, tokenType) {
async function get(tokenId, tokenType, doThrow = true) {
const res = await coll.findOne({ _id: tokenId, tokenType });
if (!res) throw new ValidationError('token');
if (!res && doThrow) throw new ValidationError('token');
return res;
}