Compare commits

..

No commits in common. "2518ced0fab78945fe29a4a136551b046f203e51" and "11943b667c322dc4017b5d9e77bcf2669ff62e30" have entirely different histories.

View file

@ -10,7 +10,7 @@ module.exports = ({ services: { sortRolesByLevel, signJwt } }) => {
const { claimsNamespace, jwtExpirationInHours } = config
function validateAuthToken(authTokenJwt) {
async function validateAuthToken(authTokenJwt) {
try {
const { authToken } = jwtDecode(authTokenJwt)
return authToken
@ -28,22 +28,22 @@ module.exports = ({ services: { sortRolesByLevel, signJwt } }) => {
let deviceId
let roles
const [row] = await sql`
SELECT
"user_id" as "userId",
"device_id" as "deviceId"
FROM
"auth_token"
WHERE
"auth_token" = ${authToken}
`
if (!row) {
try {
const [row] = await sql`
SELECT
"user_id" as "userId",
"device_id" as "deviceId"
FROM
"auth_token"
WHERE
"auth_token" = ${authToken}
`
userId = row.userId
deviceId = row.deviceId
} catch (e) {
throw httpError(410, "Auth token not found")
}
userId = row.userId
deviceId = row.deviceId
if (!userId) {
await sql.begin(async (sql) => {
await sql`set constraints all deferred`