From 67c2635d62e000a3a228a0c843ae911dedf96ffe Mon Sep 17 00:00:00 2001 From: Jackson Dean Date: Wed, 20 Sep 2023 10:04:31 -0700 Subject: [PATCH] fix: fix broken avatar directive --- src/app/avatar/avatar.directive.ts | 13 +++++++------ src/app/backend-api.service.ts | 4 ---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/app/avatar/avatar.directive.ts b/src/app/avatar/avatar.directive.ts index 0beb9b26..e574f697 100644 --- a/src/app/avatar/avatar.directive.ts +++ b/src/app/avatar/avatar.directive.ts @@ -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]', }) @@ -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. diff --git a/src/app/backend-api.service.ts b/src/app/backend-api.service.ts index 0a0ca067..56fc4827 100644 --- a/src/app/backend-api.service.ts +++ b/src/app/backend-api.service.ts @@ -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,