Repository navigation
Conversation
The login button only switched between two generic person icons, so there was no way to tell which Google account the tools were using. Request the openid, email and profile scopes alongside analytics.readonly and load the profile from the userinfo endpoint after a token is restored or granted. The profile is kept in the redux store and cleared on sign-out. The login button now shows the user's avatar with their email in the tooltip, and the desktop header also shows their name and email.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The login button only switches between two generic person icons, so there is no way to tell which Google account the tools are using. That matters for people with several Google accounts, since the account picker determines which GA properties show up.
Fix
openid,emailandprofilescopes alongsideanalytics.readonly.userinfoendpoint and keep them in the redux store (setProfile). The profile is cleared on sign-out.useLoginreturns the profile andLayoutpasses it toLogin.Loginshows the user's avatar (falling back to the existing icon), withLogout <email>as the tooltip. In the desktop header it also shows the name and email next to the avatar (showDetails).Note: the Google consent screen now also asks for permission to see the user's basic profile info and email address. Tokens granted before this change don't have these scopes; for those, the
userinforequest fails and the button falls back to the existing icon until the user signs in again.How tested
yarn check-types: no new errors (the 3 existing errors onmainare unrelated).gatsby buildsucceeds.userinforesponse: a restored token shows the avatar, name and email in the header.