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

fixes avatar directive missing photo #275

Merged
merged 1 commit into from
Sep 22, 2023
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
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