Skip to content

Commit

Permalink
Bug fix: Microsoft profile pic not showing (#9956)
Browse files Browse the repository at this point in the history
* microsoft auth api returning encoded image for profile picture, using that instead

* include optional chaining

* return an empty string if type, encoding doesn't exist in the picture
  • Loading branch information
srietkerk authored Apr 10, 2024
1 parent 820f383 commit 4a7a769
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion webapp/src/identity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,15 @@ export class UserMenu extends auth.Component<UserMenuProps, UserMenuState> {
this.props.parent.signOutGithub();
}

encodedAvatarPic(user: pxt.auth.UserProfile): string {
const type = user?.idp?.picture?.mimeType;
const encodedImg = user?.idp?.picture?.encoded;
return type && encodedImg ? `data:${type};base64,${encodedImg}` : "";
}

avatarPicUrl(): string {
const user = this.getUserProfile();
return user?.idp?.pictureUrl ?? user?.idp?.picture?.dataUrl;
return user?.idp?.pictureUrl ?? this.encodedAvatarPic(user);
}

hide() {
Expand Down

0 comments on commit 4a7a769

Please sign in to comment.