0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-14 21:32:41 +00:00
Add link to instructions to refresh Google creds
This commit is contained in:
Trevor Buckner
2022-12-10 13:34:17 -05:00
committed by GitHub
2 changed files with 17 additions and 14 deletions

View File

@@ -42,7 +42,6 @@ const AccountPage = createClass({
}, },
renderUiItems : function() { renderUiItems : function() {
// console.log(this.props.uiItems);
return <> return <>
<div className='dataGroup'> <div className='dataGroup'>
<h1>Account Information <i className='fas fa-user'></i></h1> <h1>Account Information <i className='fas fa-user'></i></h1>
@@ -51,12 +50,16 @@ const AccountPage = createClass({
</div> </div>
<div className='dataGroup'> <div className='dataGroup'>
<h3>Homebrewery Information <NaturalCritIcon /></h3> <h3>Homebrewery Information <NaturalCritIcon /></h3>
<p><strong>Brews on Homebrewery: </strong> {this.props.uiItems.mongoCount || '-'}</p> <p><strong>Brews on Homebrewery: </strong> {this.props.uiItems.mongoCount}</p>
</div> </div>
<div className='dataGroup'> <div className='dataGroup'>
<h3>Google Information <i className='fab fa-google-drive'></i></h3> <h3>Google Information <i className='fab fa-google-drive'></i></h3>
<p><strong>Linked to Google: </strong> {this.props.uiItems.googleId ? 'YES' : 'NO'}</p> <p><strong>Linked to Google: </strong> {this.props.uiItems.googleId ? 'YES' : 'NO'}</p>
{this.props.uiItems.googleId ? <p><strong>Brews on Google Drive: </strong> {this.props.uiItems.fileCount || '-'}</p> : '' } {this.props.uiItems.googleId &&
<p>
<strong>Brews on Google Drive: </strong> {this.props.uiItems.googleCount ?? <>Unable to retrieve files - <a href='https://github.com/naturalcrit/homebrewery/discussions/1580'>follow these steps to renew your Google credentials.</a></>}
</p>
}
</div> </div>
</>; </>;
}, },

View File

@@ -280,7 +280,6 @@ app.get('/edit/:id', asyncHandler(getBrew('edit')), (req, res, next)=>{
title : req.brew.title || 'Untitled Brew', title : req.brew.title || 'Untitled Brew',
description : req.brew.description || 'No description.', description : req.brew.description || 'No description.',
image : req.brew.thumbnail || defaultMetaTags.image, image : req.brew.thumbnail || defaultMetaTags.image,
type : 'article' type : 'article'
}; };
@@ -341,7 +340,7 @@ app.get('/account', asyncHandler(async (req, res, next)=>{
data.title = 'Account Information Page'; data.title = 'Account Information Page';
let auth; let auth;
let files; let googleCount = [];
if(req.account) { if(req.account) {
if(req.account.googleId) { if(req.account.googleId) {
try { try {
@@ -353,9 +352,9 @@ app.get('/account', asyncHandler(async (req, res, next)=>{
} }
if(auth.credentials.access_token) { if(auth.credentials.access_token) {
try { try {
files = await GoogleActions.listGoogleBrews(auth); googleCount = await GoogleActions.listGoogleBrews(auth);
} catch (e) { } catch (e) {
files = undefined; googleCount = undefined;
console.log('List Google files failed!'); console.log('List Google files failed!');
console.log(e); console.log(e);
} }
@@ -363,18 +362,19 @@ app.get('/account', asyncHandler(async (req, res, next)=>{
} }
const query = { authors: req.account.username, googleId: { $exists: false } }; const query = { authors: req.account.username, googleId: { $exists: false } };
const brews = await HomebrewModel.find(query, 'id') const mongoCount = await HomebrewModel.countDocuments(query)
.catch((err)=>{ .catch((err)=>{
mongoCount = 0;
console.log(err); console.log(err);
}); });
data.uiItems = { data.uiItems = {
username : req.account.username, username : req.account.username,
issued : req.account.issued, issued : req.account.issued,
mongoCount : brews.length, googleId : Boolean(req.account.googleId),
googleId : Boolean(req.account.googleId), authCheck : Boolean(req.account.googleId && auth.credentials.access_token),
authCheck : Boolean(req.account.googleId && auth.credentials.access_token), mongoCount : mongoCount,
fileCount : files?.length || '-' googleCount : googleCount?.length
}; };
} }