This commit is contained in:
Tben 2023-06-24 09:10:59 +01:00
parent cbda6d0c81
commit 84ca2fe08d
2 changed files with 50 additions and 52 deletions

View File

@ -52,62 +52,62 @@ module.exports = async function loginWithGoogle({ username, database, clientId,
document.body.appendChild(googleScript); document.body.appendChild(googleScript);
const response = await new Promise((resolve, reject) => { googleScript.onload = function (e) {
googleScript.onload = function (e) { console.log("GOOGLE script loaded!");
if (google) { console.log(element);
if (readyStateDispatch) readyStateDispatch(true); if (google) {
if (readyStateDispatch) readyStateDispatch(true);
//////////////////////////////////////// ////////////////////////////////////////
//////////////////////////////////////// ////////////////////////////////////////
//////////////////////////////////////// ////////////////////////////////////////
if (element) { if (element) {
/** /**
* Handle google credentials response * Handle google credentials response
* ======================================================== * ========================================================
* @param {object} response - Google response with credentials * @param {object} response - Google response with credentials
* @param {string} response.credential - Google access token * @param {string} response.credential - Google access token
*/ */
function handleCredentialResponse(response) { function handleCredentialResponse(response) {
userLoginWithGoogle({ userLoginWithGoogle({
gUser: null, gUser: null,
accessToken: response.credential, accessToken: response.credential,
}).then((result) => { }).then((result) => {
resolve(result); console.log(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",
}); });
} }
//////////////////////////////////////// google.accounts.id.initialize({
//////////////////////////////////////// client_id: clientId,
//////////////////////////////////////// callback: handleCredentialResponse,
});
if (triggerPrompt) { google.accounts.id.renderButton(document.getElementById("google-identity-button"), {
google.accounts.id.prompt( theme: "outline",
/** size: "large",
* Google prompt notification callback logo_alignment: "center",
* ======================================================== });
* @param {GoogleIdentityPromptNotification} notification - Notification object
*/
(notification) => {
notification.isDisplayed();
}
);
}
} }
};
}); ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
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;
}; };

View File

@ -1,6 +1,6 @@
{ {
"name": "datasquirel", "name": "datasquirel",
"version": "1.1.37", "version": "1.1.38",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {