Improve errors

This commit is contained in:
aronmal 2023-04-10 22:08:16 +02:00
parent 8193b85274
commit 2a009585f4
Signed by: aronmal
GPG key ID: 816B7707426FC612
10 changed files with 54 additions and 26 deletions

View file

@ -1,5 +1,5 @@
import jwt from "jsonwebtoken"
import errors from "../errors"
import { rejectionErrorFns } from "../errors"
import jwtVerifyCatch from "../jwtVerifyCatch"
import sendError, { API } from "./sendError"
import type { IdToken, RawToken } from "./createTokenDB"
@ -21,7 +21,7 @@ async function checkTokenIsValid(
}
// Making sure the token data is not a string (because it should be an object)
if (typeof data === "string")
return sendError(context, errors.tokenWasString(type, value))
return sendError(context, rejectionErrorFns.tokenWasString(type, value))
return next({ id: data.id, type })
}