Skip to content

Commit

Permalink
Fix: db response may be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
guimard committed Mar 22, 2024
1 parent 547dbfb commit ce3936e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/matrix-identity-server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,17 @@ export const Authenticate = (
if (token != null) {
db.get('accessTokens', ['data'], { id: token })
.then((rows) => {
callback(JSON.parse(rows[0].data as string), token)
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (!rows || rows.length === 0) {
logger.error(
`${req.socket.remoteAddress as string} sent an inexistent token ${
token as string
}`
)
send(res, 401, errMsg('unAuthorized'))
} else {
callback(JSON.parse(rows[0].data as string), token)
}
})
.catch((e) => {
logger.error(
Expand Down

0 comments on commit ce3936e

Please sign in to comment.