0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-02 06:22:43 +00:00

Merge pull request #3399 from 5e-Cleric/add-share-link-to-error-pages

Add share link to error pages ONLY IF PUBLISHED
This commit is contained in:
Trevor Buckner
2024-04-09 15:31:53 -04:00
committed by GitHub
2 changed files with 18 additions and 3 deletions

View File

@@ -73,6 +73,8 @@ const errorIndex = (props)=>{
**Properties** tab, and adding your username to the "invited authors" list. You can **Properties** tab, and adding your username to the "invited authors" list. You can
then try to access this document again. then try to access this document again.
:
**Brew Title:** ${props.brew.brewTitle || 'Unable to show title'} **Brew Title:** ${props.brew.brewTitle || 'Unable to show title'}
**Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'} **Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'}
@@ -86,9 +88,14 @@ const errorIndex = (props)=>{
You must be logged in to one of the accounts listed as an author of this brew. You must be logged in to one of the accounts listed as an author of this brew.
User is not logged in. Please log in [here](${loginUrl}). User is not logged in. Please log in [here](${loginUrl}).
:
**Brew Title:** ${props.brew.brewTitle || 'Unable to show title'} **Brew Title:** ${props.brew.brewTitle || 'Unable to show title'}
**Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'}`, **Current Authors:** ${props.brew.authors?.map((author)=>{return `[${author}](/user/${author})`;}).join(', ') || 'Unable to list authors'}
[Click here to be redirected to the brew's share page.](/share/${props.brew.shareId})`,
// Brew load error // Brew load error
'05' : dedent` '05' : dedent`
@@ -97,6 +104,8 @@ const errorIndex = (props)=>{
The server could not locate the Homebrewery document. It was likely deleted by The server could not locate the Homebrewery document. It was likely deleted by
its owner. its owner.
:
**Requested access:** ${props.brew.accessType} **Requested access:** ${props.brew.accessType}
**Brew ID:** ${props.brew.brewId}`, **Brew ID:** ${props.brew.brewId}`,
@@ -113,6 +122,8 @@ const errorIndex = (props)=>{
An error occurred while attempting to remove the Homebrewery document. An error occurred while attempting to remove the Homebrewery document.
:
**Brew ID:** ${props.brew.brewId}`, **Brew ID:** ${props.brew.brewId}`,
// Author delete error // Author delete error
@@ -121,6 +132,8 @@ const errorIndex = (props)=>{
An error occurred while attempting to remove the user from the Homebrewery document author list! An error occurred while attempting to remove the user from the Homebrewery document author list!
:
**Brew ID:** ${props.brew.brewId}`, **Brew ID:** ${props.brew.brewId}`,
// Brew locked by Administrators error // Brew locked by Administrators error
@@ -129,6 +142,8 @@ const errorIndex = (props)=>{
Please contact the Administrators to unlock this document. Please contact the Administrators to unlock this document.
:
**Brew ID:** ${props.brew.brewId} **Brew ID:** ${props.brew.brewId}
**Brew Title:** ${props.brew.brewTitle}`, **Brew Title:** ${props.brew.brewTitle}`,

View File

@@ -83,9 +83,9 @@ const api = {
if(accessType === 'edit' && (authorsExist && !(isAuthor || isInvited))) { if(accessType === 'edit' && (authorsExist && !(isAuthor || isInvited))) {
const accessError = { name: 'Access Error', status: 401 }; const accessError = { name: 'Access Error', status: 401 };
if(req.account){ if(req.account){
throw { ...accessError, message: 'User is not an Author', HBErrorCode: '03', authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId }; throw { ...accessError, message: 'User is not an Author', HBErrorCode: '03', authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId};
} }
throw { ...accessError, message: 'User is not logged in', HBErrorCode: '04', authors: stub.authors, brewTitle: stub.title }; throw { ...accessError, message: 'User is not logged in', HBErrorCode: '04', authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId};
} }
// If after all of that we still don't have a brew, throw an exception // If after all of that we still don't have a brew, throw an exception