Skip to content

Commit

Permalink
fixes avatar directive missing photo (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackson-dean authored Sep 22, 2023
1 parent 22c827a commit 30c77c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/app/avatar/avatar.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ 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 @@ -21,20 +24,17 @@ export class AvatarDirective implements OnChanges {
}

if (!this.appAvatar) {
this.setURLOnElement(
this.backendApi.GetDefaultProfilePictureURL(window.location.host)
);
this.setURLOnElement(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 30c77c0

Please sign in to comment.