Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show signed-in email in auth popup #155

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## v3.0.2 (Jan. 22, 2025)

- [#155](https://github.com/Shopify/shopify-theme-inspector/pull/155) Fix user name display

## v3.0.1 (Jan. 22, 2025)

- [#154](https://github.com/Shopify/shopify-theme-inspector/pull/154) Better error handling when the store can't be profiled
Expand Down
5 changes: 3 additions & 2 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ chrome.runtime.onMessage.addListener((message: ChromeMessage, sender, sendRespon
getOauth2Client(message.origin)
.getUserInfo()
.then(userInfo => {
const name = userInfo.given_name;
sendResponse({name});
const name = userInfo.name;
const nickname = userInfo.nickname;
sendResponse({name: name, nickname: nickname});
})
.catch(error => {
sendResponse({error});
Expand Down
12 changes: 8 additions & 4 deletions src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ async function setSignedInPopup() {
if (popupSignedIn) popupSignedIn.classList.remove('hide');
if (popupSignIn) popupSignIn.classList.add('hide');

const name = await getUserName();
popupSignedInPrompt!.textContent = `${name}`;
const { name, nickname } = await getUserName();
const displayText = nickname ? `${name} (${nickname})` : name;
popupSignedInPrompt!.textContent = displayText;
}

function setSignInPopup() {
Expand Down Expand Up @@ -94,7 +95,7 @@ if (signOutButton) {
});
}

async function getUserName(): Promise<string> {
async function getUserName(): Promise<{ name: string; nickname?: string }> {
const {origin} = await getActiveTabURL();
return chrome.runtime.sendMessage({
type: 'request-user-name',
Expand All @@ -103,7 +104,10 @@ async function getUserName(): Promise<string> {
if (response?.error) {
throw new Error(response.error);
}
return response.name || '';
return {
name: response.name || '',
nickname: response.nickname
};
});
}

Expand Down
1 change: 1 addition & 0 deletions src/types/UserInfo.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface UserInfo {
nickname: any;
email: string;
email_verified: boolean;
family_name: string;
Expand Down
1 change: 1 addition & 0 deletions src/types/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface AuthResponse {

export interface UserNameResponse {
name?: string;
nickname?: string;
error?: string;
}

Expand Down
Loading