Skip to content

Commit

Permalink
Fix null pointers when auth token is missing
Browse files Browse the repository at this point in the history
(fixes #1628 and similar issue in data export route)
  • Loading branch information
bkimminich committed May 18, 2021
1 parent 54aa467 commit 60e1d3d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion routes/dataExport.ts
Expand Up @@ -11,7 +11,7 @@ import models = require('../models/index')

module.exports = function dataExport () {
return async (req, res, next) => {
const loggedInUser = security.authenticatedUsers.get(req.headers.authorization.replace('Bearer ', ''))
const loggedInUser = security.authenticatedUsers.get(req.headers?.authorization?.replace('Bearer ', ''))
if (loggedInUser?.data?.email && loggedInUser.data.id) {
const username = loggedInUser.data.username
const email = loggedInUser.data.email
Expand Down
2 changes: 1 addition & 1 deletion routes/orderHistory.ts
Expand Up @@ -8,7 +8,7 @@ import db = require('../data/mongodb')

module.exports.orderHistory = function orderHistory () {
return async (req, res, next) => {
const loggedInUser = security.authenticatedUsers.get(req.headers.authorization.replace('Bearer ', ''))
const loggedInUser = security.authenticatedUsers.get(req.headers?.authorization?.replace('Bearer ', ''))
if (loggedInUser?.data?.email && loggedInUser.data.id) {
const email = loggedInUser.data.email
const updatedEmail = email.replace(/[aeiou]/gi, '*')
Expand Down

0 comments on commit 60e1d3d

Please sign in to comment.