Browse Source

Fix impersonation in performance endpoint

pull/239/head
Thomas 4 years ago
parent
commit
21570cca19
  1. 8
      apps/api/src/app/portfolio/portfolio.controller.ts
  2. 7
      apps/api/src/app/portfolio/portfolio.service.ts

8
apps/api/src/app/portfolio/portfolio.controller.ts

@ -236,14 +236,8 @@ export class PortfolioController {
@Query('range') range, @Query('range') range,
@Res() res: Response @Res() res: Response
): Promise<PortfolioPerformance> { ): Promise<PortfolioPerformance> {
const impersonationUserId =
await this.impersonationService.validateImpersonationId(
impersonationId,
this.request.user.id
);
const performanceInformation = await this.portfolioService.getPerformance( const performanceInformation = await this.portfolioService.getPerformance(
impersonationUserId, impersonationId,
range range
); );

7
apps/api/src/app/portfolio/portfolio.service.ts

@ -527,12 +527,7 @@ export class PortfolioService {
aImpersonationId: string, aImpersonationId: string,
aDateRange: DateRange = 'max' aDateRange: DateRange = 'max'
): Promise<{ hasErrors: boolean; performance: PortfolioPerformance }> { ): Promise<{ hasErrors: boolean; performance: PortfolioPerformance }> {
const impersonationUserId = const userId = await this.getUserId(aImpersonationId);
await this.impersonationService.validateImpersonationId(
aImpersonationId,
this.request.user.id
);
const userId = impersonationUserId || this.request.user.id;
const portfolioCalculator = new PortfolioCalculator( const portfolioCalculator = new PortfolioCalculator(
this.currentRateService, this.currentRateService,

Loading…
Cancel
Save