Skip to content

Commit 6557460

Browse files
committed
debug auth user
1 parent 6080e8e commit 6557460

File tree

1 file changed

+5
-2
lines changed
  • src/routes/copilotOpportunity

1 file changed

+5
-2
lines changed

src/routes/copilotOpportunity/get.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ module.exports = [
3333
.then((copilotOpportunity) => {
3434
const plainOpportunity = copilotOpportunity.get({ plain: true });
3535
req.log.info("authUser", req.authUser);
36-
const memberIds = plainOpportunity.project.members.map((member) => member.userId);
37-
const canApplyAsCopilot = !memberIds.includes(req.authUser.userId)
36+
const memberIds = plainOpportunity.project.members && plainOpportunity.project.members.map((member) => member.userId);
37+
let canApplyAsCopilot = false;
38+
if (req.authUser) {
39+
canApplyAsCopilot = !memberIds.includes(req.authUser.userId)
40+
}
3841
// This shouldn't be exposed to the clientside
3942
delete plainOpportunity.project.members;
4043
const formattedOpportunity = Object.assign({

0 commit comments

Comments
 (0)