From 7df3b8c4724678de51820026d39e64fbaf9d705c Mon Sep 17 00:00:00 2001 From: Robert Helmer Date: Wed, 16 Jun 2021 19:50:16 -0700 Subject: [PATCH 1/2] pull in sample google auth integration code so web site can get the google auth token if the user is already logged in --- public/index.html | 64 ++++++++++++++++++++++++++++++----------- website/web-site-api.js | 18 ++++++------ 2 files changed, 57 insertions(+), 25 deletions(-) diff --git a/public/index.html b/public/index.html index 9354bfb7..503fbb8f 100644 --- a/public/index.html +++ b/public/index.html @@ -1,24 +1,54 @@ - - - - Rally: Put your data to work for a better internet + + + + + + - - - - - - + Rally: Put your data to work for a better internet - - - + + + + + + - - + + + - - + + +
+ + + + + + + + \ No newline at end of file diff --git a/website/web-site-api.js b/website/web-site-api.js index 5c61e8d8..a376f834 100644 --- a/website/web-site-api.js +++ b/website/web-site-api.js @@ -77,13 +77,7 @@ export default { // create a new user. user.initialize(userCredential.user.uid, { createUser: true }); listenForUserChanges(userCredential.user); - - // Attempt to automatically log-in any valid study extensions, by passing them the ID token. - // TODO only supports Chrome auth provider - // TODO pull study IDs from metadata - for (const studyId of ["maoohlacnogbjgacnnoajgljfcdbdocb"]) { - chrome.runtime.sendMessage(studyId, userCredential.credential.idToken); - } + await this.notifyStudies(userCredential.credential.idToken); }, async loginWithEmailAndPassword(email, password) { let userCredential; @@ -134,7 +128,6 @@ export default { userState = await user.get(authenticatedUser.uid); userState = userState.data(); listenForUserChanges(authenticatedUser); - } else { initialState._isLoggedIn = false; } @@ -158,6 +151,15 @@ export default { }, + async notifyStudies(idToken) { + // Attempt to automatically log-in any valid study extensions, by passing them the ID token. + // TODO only supports Chrome auth provider + // TODO pull study IDs from metadata + for (const studyId of ["maoohlacnogbjgacnnoajgljfcdbdocb"]) { + chrome.runtime.sendMessage(studyId, idToken); + } + }, + async updateStudyEnrollment(studyID, enroll) { const enrolledStudies = { ...(state.user.enrolledStudies || {}) }; if (!(studyID in enrolledStudies)) { enrolledStudies[studyID] = {}; } From cf19f6a6bdb740d459db0784a1c76f535c438fb6 Mon Sep 17 00:00:00 2001 From: Robert Helmer Date: Wed, 16 Jun 2021 20:28:00 -0700 Subject: [PATCH 2/2] hide google sign-in widget --- public/rally.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/rally.css b/public/rally.css index bb3000c6..1a661ec5 100644 --- a/public/rally.css +++ b/public/rally.css @@ -332,3 +332,8 @@ src/components/icons/ExternalLink.svelte: grid-auto-flow: column; grid-column-gap: var(--gap, 12px); } + +/* hide the google sign-in widget */ +.social_signin { + display: none; +} \ No newline at end of file