Skip to content

Commit

Permalink
fix(UserEntityService): meProfile fetch problem
Browse files Browse the repository at this point in the history
  • Loading branch information
SWREI committed Aug 27, 2024
1 parent 9319fa3 commit 6bc7158
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/backend/src/core/entities/UserEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,13 @@ export class UserEntityService implements OnModuleInit {
}, options);

const user = typeof src === 'object' ? src : await this.usersRepository.findOneByOrFail({ id: src });
const meObject = await this.usersRepository.findOneByOrFail({ id: me?.id });
const meProfile = await this.userProfilesRepository.findOneByOrFail({ userId: user.id });

const isDetailed = opts.schema !== 'UserLite';
const meId = me ? me.id : null;
const isMe = meId === user.id;
const iAmModerator = me ? (await this.roleService.isModerator(me as MiUser)) && !meObject.isVacation && meProfile.twoFactorEnabled : false;
const meObject = await this.usersRepository.findOneBy({ id: me?.id });
const meProfile = await this.userProfilesRepository.findOneBy({ userId: me?.id });
const iAmModerator = me ? (await this.roleService.isModerator(me as MiUser)) && !meObject?.isVacation && meProfile?.twoFactorEnabled : false;
if (user.isSuspended && !iAmModerator) throw new IdentifiableError('85ab9bd7-3a41-4530-959d-f07073900109', `User ${user.id} has been suspended.`);

const profile = isDetailed
Expand Down

0 comments on commit 6bc7158

Please sign in to comment.