0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 07:43:20 +00:00

Use personal auth if logged in via google.

This commit is contained in:
Trevor Buckner
2024-09-29 21:47:45 -04:00
parent ea656e5119
commit 8ab6a8599d
2 changed files with 14 additions and 3 deletions

View File

@@ -147,8 +147,10 @@ const GoogleActions = {
return brews;
},
updateGoogleBrew : async (brew)=>{
const drive = googleDrive.drive({ version: 'v3', auth: defaultAuth });
updateGoogleBrew : async (brew, auth = defaultAuth)=>{
const drive = googleDrive.drive({ version: 'v3', auth: auth });
console.log(auth == defaultAuth ? 'UPDATE w SERVICEACC' : 'UPDATE w USERACC')
await drive.files.update({
fileId : brew.googleId,

View File

@@ -353,7 +353,7 @@ const api = {
if(!brew.googleId) return;
} else if(brew.googleId) {
// If the google id exists and no other actions are being performed, update the google brew
const updated = await GoogleActions.updateGoogleBrew(api.excludeGoogleProps(brew));
const updated = await api.updateGoogleBrew(req.account, api.excludeGoogleProps(brew), res);
if(!updated) return;
}
@@ -397,6 +397,15 @@ const api = {
res.status(200).send(saved);
},
updateGoogleBrew : async (account, brew, res)=>{
let oAuth2Client;
if(account.googleId)
oAuth2Client = GoogleActions.authCheck(account, res);
return await GoogleActions.updateGoogleBrew(brew, oAuth2Client);
},
deleteGoogleBrew : async (account, id, editId, res)=>{
const auth = await GoogleActions.authCheck(account, res);
await GoogleActions.deleteGoogleBrew(auth, id, editId);