Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
fix(core): use toObject to hide owner field
Browse files Browse the repository at this point in the history
  • Loading branch information
Juknum committed Nov 8, 2023
1 parent 3a8a891 commit 40e995e
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/modules/files/files.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class FilesController {
const file = await this.filesService.findOne(id);
await file.visibility?.init();

if (await this.filesService.canReadFile(file, req.user as User)) return file;
if (await this.filesService.canReadFile(file, req.user as User)) return file.toObject();
throw new UnauthorizedException(this.t.Errors.File.Unauthorized(file.visibility?.name));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class PromotionPicture extends File<Promotion> implements PromotionPictur
@OneToOne(() => Promotion, (promotion) => promotion.picture, { nullable: true, owner: true })
picture_promotion: Promotion;

@Property({ persist: false })
@Property({ persist: false, hidden: true })
get owner(): Promotion {
return this.picture_promotion;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/users/entities/user-banner.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class UserBanner extends File<User> implements UserBannerEntity<User> {
@OneToOne(() => User, (user) => user.banner, { nullable: true, owner: true })
banner_user: User;

@Property({ persist: false })
@Property({ persist: false, hidden: true })
get owner(): User {
return this.banner_user;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/users/entities/user-picture.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class UserPicture extends File<User> implements UserPictureEntity<User> {
@OneToOne(() => User, (user) => user.picture, { nullable: true, owner: true })
picture_user: User;

@Property({ persist: false })
@Property({ persist: false, hidden: true })
get owner(): User {
return this.picture_user;
}
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/files.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ describe('Files (e2e)', () => {
id: file.id,
filename: 'test.png',
mimetype: 'image/png',
path: 'test.png',
size: 123,
visibility: file.visibility.id,
description: 'foo bar',
Expand Down

0 comments on commit 40e995e

Please sign in to comment.