From 3949bf7cc10419f19b489a3fb9194fefae0dab24 Mon Sep 17 00:00:00 2001 From: Tben <52448020+BenjaminToby@users.noreply.github.com> Date: Sat, 24 Jun 2023 14:28:36 +0100 Subject: [PATCH] updates --- client/auth/logout.js | 65 +++++++++++++++++++++++++------------------ package.json | 2 +- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/client/auth/logout.js b/client/auth/logout.js index b53433d..121a96a 100644 --- a/client/auth/logout.js +++ b/client/auth/logout.js @@ -19,12 +19,15 @@ const parseClientCookies = require("../utils/parseClientCookies"); * * @async * + * @param {object} params - Single object passed + * @param {string|null} params.googleClientId - Google client Id if applicable + * * @requires localStorageUser - a "user" JSON string stored in local storage with all * the necessary user data gotten from the server * * @returns {Promise} - Return */ -module.exports = async function logout() { +module.exports = async function logout(params) { /** * == Initialize * @@ -73,37 +76,45 @@ module.exports = async function logout() { ////////////////////////////////////////////////////////////////////////////////// if (socialId) { - const googleScript = document.createElement("script"); - googleScript.src = "https://accounts.google.com/gsi/client"; - googleScript.className = "social-script-tag"; + const googleClientId = params.googleClientId; - document.body.appendChild(googleScript); + if (googleClientId) { + const googleScript = document.createElement("script"); + googleScript.src = "https://accounts.google.com/gsi/client"; + googleScript.className = "social-script-tag"; + + document.body.appendChild(googleScript); + + //////////////////////////////////////// + //////////////////////////////////////// + //////////////////////////////////////// + + googleScript.onload = function (e) { + if (google) { + //////////////////////////////////////// + //////////////////////////////////////// + //////////////////////////////////////// + + google.accounts.id.initialize({ + client_id: googleClientId, + }); + + google.accounts.id.revoke(socialId, (done) => { + console.log(done.error); + + resolve(true); + }); + + //////////////////////////////////////// + //////////////////////////////////////// + //////////////////////////////////////// + } + }; + } //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// - - googleScript.onload = function (e) { - if (google) { - //////////////////////////////////////// - //////////////////////////////////////// - //////////////////////////////////////// - - google.accounts.id.initialize({ - client_id: clientId, - }); - - google.accounts.id.revoke(socialId, (done) => { - console.log(done.error); - - resolve(true); - }); - - //////////////////////////////////////// - //////////////////////////////////////// - //////////////////////////////////////// - } - }; } else { resolve(true); } diff --git a/package.json b/package.json index ffa8ccc..f4e006c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.1.47", + "version": "1.1.48", "description": "Cloud-based SQL data management tool", "main": "index.js", "scripts": {