From c0164dce6a077a4230ba618d4c6488bbe31200ee Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 26 Jun 2023 17:02:28 -0400 Subject: [PATCH] Fix for username undefined (not logged in) --- server/homebrew.api.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index f82a9b642..9e00b46b2 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -59,7 +59,12 @@ const api = { // Throw any error caught while attempting to retrieve Google brew. if(googleError) { const reason = googleError.errors[0].reason; - throw { ...googleError, HBErrorCode: reason == 'notFound' ? '02' : '01', authors: stub?.authors, account: req.account.username }; + if(reason == 'notFound') { + throw { ...googleError, HBErrorCode: '02', authors: stub?.authors, account: req.account?.username }; + } + else { + throw { ...googleError, HBErrorCode: '01'}; + } } // Combine the Homebrewery stub with the google brew, or if the stub doesn't exist just use the google brew stub = stub ? _.assign({ ...api.excludeStubProps(stub), stubbed: true }, api.excludeGoogleProps(googleBrew)) : googleBrew;