Skip to content

Commit

Permalink
Fix: wrap async method in try catch (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderleegs committed Jun 22, 2023
1 parent 60f3331 commit 32ef92c
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/middleware/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,25 @@ export class AuthenticationMiddleware {
next: NextFunction
) {
const { cookies, originalUrl: url, session } = req
const {
isomerUserId,
email,
...rest
} = await this.authenticationMiddlewareService.verifyAccess({
cookies,
url,
userInfo: session.userInfo,
})
const userSessionData = new UserSessionData({
isomerUserId,
email,
...rest,
})
res.locals.userSessionData = userSessionData
return next()
try {
const {
isomerUserId,
email,
...rest
} = await this.authenticationMiddlewareService.verifyAccess({
cookies,
url,
userInfo: session.userInfo,
})
const userSessionData = new UserSessionData({
isomerUserId,
email,
...rest,
})
res.locals.userSessionData = userSessionData
return next()
} catch (err) {
return next(err)
}
}
}

0 comments on commit 32ef92c

Please sign in to comment.