Compare commits
No commits in common. "2518ced0fab78945fe29a4a136551b046f203e51" and "11943b667c322dc4017b5d9e77bcf2669ff62e30" have entirely different histories.
2518ced0fa
...
11943b667c
1 changed files with 14 additions and 14 deletions
|
@ -10,7 +10,7 @@ module.exports = ({ services: { sortRolesByLevel, signJwt } }) => {
|
||||||
|
|
||||||
const { claimsNamespace, jwtExpirationInHours } = config
|
const { claimsNamespace, jwtExpirationInHours } = config
|
||||||
|
|
||||||
function validateAuthToken(authTokenJwt) {
|
async function validateAuthToken(authTokenJwt) {
|
||||||
try {
|
try {
|
||||||
const { authToken } = jwtDecode(authTokenJwt)
|
const { authToken } = jwtDecode(authTokenJwt)
|
||||||
return authToken
|
return authToken
|
||||||
|
@ -28,6 +28,7 @@ module.exports = ({ services: { sortRolesByLevel, signJwt } }) => {
|
||||||
let deviceId
|
let deviceId
|
||||||
let roles
|
let roles
|
||||||
|
|
||||||
|
try {
|
||||||
const [row] = await sql`
|
const [row] = await sql`
|
||||||
SELECT
|
SELECT
|
||||||
"user_id" as "userId",
|
"user_id" as "userId",
|
||||||
|
@ -37,12 +38,11 @@ module.exports = ({ services: { sortRolesByLevel, signJwt } }) => {
|
||||||
WHERE
|
WHERE
|
||||||
"auth_token" = ${authToken}
|
"auth_token" = ${authToken}
|
||||||
`
|
`
|
||||||
if (!row) {
|
|
||||||
throw httpError(410, "Auth token not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
userId = row.userId
|
userId = row.userId
|
||||||
deviceId = row.deviceId
|
deviceId = row.deviceId
|
||||||
|
} catch (e) {
|
||||||
|
throw httpError(410, "Auth token not found")
|
||||||
|
}
|
||||||
|
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
await sql.begin(async (sql) => {
|
await sql.begin(async (sql) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue