From 84ca2fe08d6926b6a926a75dcb406d50a022eeec Mon Sep 17 00:00:00 2001 From: Tben <52448020+BenjaminToby@users.noreply.github.com> Date: Sat, 24 Jun 2023 09:10:59 +0100 Subject: [PATCH] updates --- client/auth/loginWithGoogle.js | 100 ++++++++++++++++----------------- package.json | 2 +- 2 files changed, 50 insertions(+), 52 deletions(-) diff --git a/client/auth/loginWithGoogle.js b/client/auth/loginWithGoogle.js index 22b4943..d85973b 100644 --- a/client/auth/loginWithGoogle.js +++ b/client/auth/loginWithGoogle.js @@ -52,62 +52,62 @@ module.exports = async function loginWithGoogle({ username, database, clientId, document.body.appendChild(googleScript); - const response = await new Promise((resolve, reject) => { - googleScript.onload = function (e) { - if (google) { - if (readyStateDispatch) readyStateDispatch(true); + googleScript.onload = function (e) { + console.log("GOOGLE script loaded!"); + console.log(element); + if (google) { + if (readyStateDispatch) readyStateDispatch(true); - //////////////////////////////////////// - //////////////////////////////////////// - //////////////////////////////////////// + //////////////////////////////////////// + //////////////////////////////////////// + //////////////////////////////////////// - if (element) { - /** - * Handle google credentials response - * ======================================================== - * @param {object} response - Google response with credentials - * @param {string} response.credential - Google access token - */ - function handleCredentialResponse(response) { - userLoginWithGoogle({ - gUser: null, - accessToken: response.credential, - }).then((result) => { - resolve(result); - }); - } - - google.accounts.id.initialize({ - client_id: clientId, - callback: handleCredentialResponse, - }); - - google.accounts.id.renderButton(document.getElementById("google-identity-button"), { - theme: "outline", - size: "large", - logo_alignment: "center", + if (element) { + /** + * Handle google credentials response + * ======================================================== + * @param {object} response - Google response with credentials + * @param {string} response.credential - Google access token + */ + function handleCredentialResponse(response) { + userLoginWithGoogle({ + gUser: null, + accessToken: response.credential, + }).then((result) => { + console.log(result); }); } - //////////////////////////////////////// - //////////////////////////////////////// - //////////////////////////////////////// + google.accounts.id.initialize({ + client_id: clientId, + callback: handleCredentialResponse, + }); - if (triggerPrompt) { - google.accounts.id.prompt( - /** - * Google prompt notification callback - * ======================================================== - * @param {GoogleIdentityPromptNotification} notification - Notification object - */ - (notification) => { - notification.isDisplayed(); - } - ); - } + google.accounts.id.renderButton(document.getElementById("google-identity-button"), { + theme: "outline", + size: "large", + logo_alignment: "center", + }); } - }; - }); + + //////////////////////////////////////// + //////////////////////////////////////// + //////////////////////////////////////// + + if (triggerPrompt) { + google.accounts.id.prompt( + /** + * Google prompt notification callback + * ======================================================== + * @param {GoogleIdentityPromptNotification} notification - Notification object + */ + (notification) => { + notification.isDisplayed(); + } + ); + } + } + }; ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// @@ -178,6 +178,4 @@ module.exports = async function loginWithGoogle({ username, database, clientId, ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// - - return response; }; diff --git a/package.json b/package.json index 118bec2..33f0f97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.1.37", + "version": "1.1.38", "description": "Cloud-based SQL data management tool", "main": "index.js", "scripts": {