mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-02 21:32:42 +00:00
Fix case where no stub is found
When retrieving a Google Brew with no stub yet, if the user is not logged in or has expired credentials, we enter this error handler. However, the error message itself tries to send a list of authors. If there was no stub, we crash here with a 500 error. This adds conditional operator to any stub value so we can send the actual "not logged in" error in case of no stub.
This commit is contained in:
@@ -111,7 +111,7 @@ const api = {
|
|||||||
const isInvited = stub?.invitedAuthors?.includes(req.account?.username);
|
const isInvited = stub?.invitedAuthors?.includes(req.account?.username);
|
||||||
|
|
||||||
if(accessType === 'edit' && !(isOwner || isAuthor || isInvited)) {
|
if(accessType === 'edit' && !(isOwner || isAuthor || isInvited)) {
|
||||||
const accessError = { name: 'Access Error', status: 401, authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId };
|
const accessError = { name: 'Access Error', status: 401, authors: stub?.authors, brewTitle: stub?.title, shareId: stub?.shareId };
|
||||||
if(req.account)
|
if(req.account)
|
||||||
throw { ...accessError, message: 'User is not an Author', HBErrorCode: '03' };
|
throw { ...accessError, message: 'User is not an Author', HBErrorCode: '03' };
|
||||||
else
|
else
|
||||||
@@ -119,7 +119,7 @@ const api = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(stub?.lock?.locked && accessType != 'edit') {
|
if(stub?.lock?.locked && accessType != 'edit') {
|
||||||
throw { HBErrorCode: '51', code: stub.lock.code, message: stub.lock.shareMessage, brewId: stub.shareId, brewTitle: stub.title };
|
throw { HBErrorCode: '51', code: stub?.lock.code, message: stub?.lock.shareMessage, brewId: stub?.shareId, brewTitle: stub?.title };
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a google id, try to find the google brew
|
// If there is a google id, try to find the google brew
|
||||||
|
|||||||
Reference in New Issue
Block a user