mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-03 14:52:38 +00:00
Use personal auth if logged in via google.
This commit is contained in:
@@ -147,8 +147,10 @@ const GoogleActions = {
|
|||||||
return brews;
|
return brews;
|
||||||
},
|
},
|
||||||
|
|
||||||
updateGoogleBrew : async (brew)=>{
|
updateGoogleBrew : async (brew, auth = defaultAuth)=>{
|
||||||
const drive = googleDrive.drive({ version: 'v3', auth: defaultAuth });
|
const drive = googleDrive.drive({ version: 'v3', auth: auth });
|
||||||
|
|
||||||
|
console.log(auth == defaultAuth ? 'UPDATE w SERVICEACC' : 'UPDATE w USERACC')
|
||||||
|
|
||||||
await drive.files.update({
|
await drive.files.update({
|
||||||
fileId : brew.googleId,
|
fileId : brew.googleId,
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ const api = {
|
|||||||
if(!brew.googleId) return;
|
if(!brew.googleId) return;
|
||||||
} else if(brew.googleId) {
|
} else if(brew.googleId) {
|
||||||
// If the google id exists and no other actions are being performed, update the google brew
|
// 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;
|
if(!updated) return;
|
||||||
}
|
}
|
||||||
@@ -397,6 +397,15 @@ const api = {
|
|||||||
|
|
||||||
res.status(200).send(saved);
|
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)=>{
|
deleteGoogleBrew : async (account, id, editId, res)=>{
|
||||||
const auth = await GoogleActions.authCheck(account, res);
|
const auth = await GoogleActions.authCheck(account, res);
|
||||||
await GoogleActions.deleteGoogleBrew(auth, id, editId);
|
await GoogleActions.deleteGoogleBrew(auth, id, editId);
|
||||||
|
|||||||
Reference in New Issue
Block a user