Skip to content

Commit

Permalink
fix: fix broken avatar directive
Browse files Browse the repository at this point in the history
  • Loading branch information
jackson-dean committed Sep 21, 2023
1 parent 8d0c9d4 commit 6384f1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 7 additions & 6 deletions src/app/avatar/avatar.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import _ from 'lodash';
import { BackendAPIService } from '../backend-api.service';
import { GlobalVarsService } from '../global-vars.service';

const DEFAULT_PROFILE_PIC_URL = window.location.origin + '/assets/placeholder-account-image.png';

@Directive({
selector: '[appAvatar]',
})
Expand All @@ -22,19 +24,18 @@ export class AvatarDirective implements OnChanges {

if (!this.appAvatar) {
this.setURLOnElement(
this.backendApi.GetDefaultProfilePictureURL(window.location.host)
DEFAULT_PROFILE_PIC_URL
);
return;
}
// The fallback route is the route to the pic we use if we can't find an avatar for the user.
const fallbackRoute = `fallback=${this.backendApi.GetDefaultProfilePictureURL(
window.location.host
)}`;

// Although it would be hard for an attacker to inject a malformed public key into the app,
// we do a basic _.escape anyways just to be extra safe.
const profPicURL = _.escape(
this.backendApi.GetSingleProfilePictureURL(this.appAvatar, fallbackRoute)
this.backendApi.GetSingleProfilePictureURL(
this.appAvatar,
DEFAULT_PROFILE_PIC_URL
)
);

// Set the URL on the element.
Expand Down
4 changes: 0 additions & 4 deletions src/app/backend-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,6 @@ export class BackendAPIService {
)}/${PublicKeyBase58Check}?fallback=${FallbackURL}`;
}

GetDefaultProfilePictureURL(defaultImgHost: string): string {
return defaultImgHost + '/assets/img/default_profile_pic.png';
}

JumioBegin(
PublicKey: string,
ReferralHashBase58: string,
Expand Down

0 comments on commit 6384f1b

Please sign in to comment.