|
|
@ -14,7 +14,6 @@ import { ApiService } from '@ghostfolio/api/services/api/api.service'; |
|
|
|
import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; |
|
|
|
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data/exchange-rate-data.service'; |
|
|
|
import { ImpersonationService } from '@ghostfolio/api/services/impersonation/impersonation.service'; |
|
|
|
import { UserHelperService } from '@ghostfolio/api/services/user-helper/user-helper.service'; |
|
|
|
import { |
|
|
|
DEFAULT_CURRENCY, |
|
|
|
HEADER_KEY_IMPERSONATION |
|
|
@ -28,6 +27,10 @@ import { |
|
|
|
PortfolioPublicDetails, |
|
|
|
PortfolioReport |
|
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
|
import { |
|
|
|
hasReadRestrictedAccessPermission, |
|
|
|
isRestrictedView |
|
|
|
} from '@ghostfolio/common/permissions'; |
|
|
|
import type { |
|
|
|
DateRange, |
|
|
|
GroupBy, |
|
|
@ -66,7 +69,6 @@ export class PortfolioController { |
|
|
|
private readonly orderService: OrderService, |
|
|
|
private readonly portfolioService: PortfolioService, |
|
|
|
@Inject(REQUEST) private readonly request: RequestWithUser, |
|
|
|
private readonly userHelperService: UserHelperService, |
|
|
|
private readonly userService: UserService |
|
|
|
) {} |
|
|
|
|
|
|
@ -86,11 +88,6 @@ export class PortfolioController { |
|
|
|
|
|
|
|
let hasDetails = true; |
|
|
|
let hasError = false; |
|
|
|
const hasReadRestrictedAccessPermission = |
|
|
|
this.userHelperService.hasReadRestrictedAccessPermission({ |
|
|
|
impersonationId, |
|
|
|
user: this.request.user |
|
|
|
}); |
|
|
|
|
|
|
|
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { |
|
|
|
hasDetails = this.request.user.subscription.type === 'Premium'; |
|
|
@ -119,8 +116,11 @@ export class PortfolioController { |
|
|
|
let portfolioSummary = summary; |
|
|
|
|
|
|
|
if ( |
|
|
|
hasReadRestrictedAccessPermission || |
|
|
|
this.userHelperService.isRestrictedView(this.request.user) |
|
|
|
hasReadRestrictedAccessPermission({ |
|
|
|
impersonationId, |
|
|
|
user: this.request.user |
|
|
|
}) || |
|
|
|
isRestrictedView(this.request.user) |
|
|
|
) { |
|
|
|
const totalInvestment = Object.values(holdings) |
|
|
|
.map(({ investment }) => { |
|
|
@ -160,8 +160,11 @@ export class PortfolioController { |
|
|
|
|
|
|
|
if ( |
|
|
|
hasDetails === false || |
|
|
|
hasReadRestrictedAccessPermission || |
|
|
|
this.userHelperService.isRestrictedView(this.request.user) |
|
|
|
hasReadRestrictedAccessPermission({ |
|
|
|
impersonationId, |
|
|
|
user: this.request.user |
|
|
|
}) || |
|
|
|
isRestrictedView(this.request.user) |
|
|
|
) { |
|
|
|
portfolioSummary = nullifyValuesInObject(summary, [ |
|
|
|
'cash', |
|
|
@ -228,12 +231,6 @@ export class PortfolioController { |
|
|
|
@Query('range') dateRange: DateRange = 'max', |
|
|
|
@Query('tags') filterByTags?: string |
|
|
|
): Promise<PortfolioDividends> { |
|
|
|
const hasReadRestrictedAccessPermission = |
|
|
|
this.userHelperService.hasReadRestrictedAccessPermission({ |
|
|
|
impersonationId, |
|
|
|
user: this.request.user |
|
|
|
}); |
|
|
|
|
|
|
|
const filters = this.apiService.buildFiltersFromQueryParams({ |
|
|
|
filterByAccounts, |
|
|
|
filterByAssetClasses, |
|
|
@ -261,8 +258,11 @@ export class PortfolioController { |
|
|
|
}); |
|
|
|
|
|
|
|
if ( |
|
|
|
hasReadRestrictedAccessPermission || |
|
|
|
this.userHelperService.isRestrictedView(this.request.user) |
|
|
|
hasReadRestrictedAccessPermission({ |
|
|
|
impersonationId, |
|
|
|
user: this.request.user |
|
|
|
}) || |
|
|
|
isRestrictedView(this.request.user) |
|
|
|
) { |
|
|
|
const maxDividend = dividends.reduce( |
|
|
|
(investment, item) => Math.max(investment, item.investment), |
|
|
@ -328,12 +328,6 @@ export class PortfolioController { |
|
|
|
@Query('range') dateRange: DateRange = 'max', |
|
|
|
@Query('tags') filterByTags?: string |
|
|
|
): Promise<PortfolioInvestments> { |
|
|
|
const hasReadRestrictedAccessPermission = |
|
|
|
this.userHelperService.hasReadRestrictedAccessPermission({ |
|
|
|
impersonationId, |
|
|
|
user: this.request.user |
|
|
|
}); |
|
|
|
|
|
|
|
const filters = this.apiService.buildFiltersFromQueryParams({ |
|
|
|
filterByAccounts, |
|
|
|
filterByAssetClasses, |
|
|
@ -349,8 +343,11 @@ export class PortfolioController { |
|
|
|
}); |
|
|
|
|
|
|
|
if ( |
|
|
|
hasReadRestrictedAccessPermission || |
|
|
|
this.userHelperService.isRestrictedView(this.request.user) |
|
|
|
hasReadRestrictedAccessPermission({ |
|
|
|
impersonationId, |
|
|
|
user: this.request.user |
|
|
|
}) || |
|
|
|
isRestrictedView(this.request.user) |
|
|
|
) { |
|
|
|
const maxInvestment = investments.reduce( |
|
|
|
(investment, item) => Math.max(investment, item.investment), |
|
|
@ -399,12 +396,6 @@ export class PortfolioController { |
|
|
|
): Promise<PortfolioPerformanceResponse> { |
|
|
|
const withExcludedAccounts = withExcludedAccountsParam === 'true'; |
|
|
|
|
|
|
|
const hasReadRestrictedAccessPermission = |
|
|
|
this.userHelperService.hasReadRestrictedAccessPermission({ |
|
|
|
impersonationId, |
|
|
|
user: this.request.user |
|
|
|
}); |
|
|
|
|
|
|
|
const filters = this.apiService.buildFiltersFromQueryParams({ |
|
|
|
filterByAccounts, |
|
|
|
filterByAssetClasses, |
|
|
@ -420,9 +411,12 @@ export class PortfolioController { |
|
|
|
}); |
|
|
|
|
|
|
|
if ( |
|
|
|
hasReadRestrictedAccessPermission || |
|
|
|
this.request.user.Settings.settings.viewMode === 'ZEN' || |
|
|
|
this.userHelperService.isRestrictedView(this.request.user) |
|
|
|
hasReadRestrictedAccessPermission({ |
|
|
|
impersonationId, |
|
|
|
user: this.request.user |
|
|
|
}) || |
|
|
|
isRestrictedView(this.request.user) || |
|
|
|
this.request.user.Settings.settings.viewMode === 'ZEN' |
|
|
|
) { |
|
|
|
performanceInformation.chart = performanceInformation.chart.map( |
|
|
|
({ |
|
|
|