Skip to content

Commit

Permalink
add check if user is authorized
Browse files Browse the repository at this point in the history
  • Loading branch information
hoeppner-dataport committed Nov 3, 2023
1 parent 389e127 commit e8fb31b
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Injectable } from '@nestjs/common';
import { Injectable, UnauthorizedException } from '@nestjs/common';
import { EntityId } from '@shared/domain';
import { LegacyLogger } from '@src/core/logger';
import { AuthorizationService } from '@src/modules/authorization';
import { MetaData, MetaTagExtractorService } from '../service';

@Injectable()
export class MetaTagExtractorUc {
constructor(
// private readonly authorizationService: AuthorizationService,
private readonly authorizationService: AuthorizationService,
private readonly metaTagExtractorService: MetaTagExtractorService,
private readonly logger: LegacyLogger
) {
Expand All @@ -16,9 +17,12 @@ export class MetaTagExtractorUc {
async fetchMetaData(userId: EntityId, url: string): Promise<MetaData> {
this.logger.debug({ action: 'fetchMetaData', userId });

const result = await this.metaTagExtractorService.fetchMetaData(url);
// WIP: check permission
const user = await this.authorizationService.getUserWithPermissions(userId);
if (!user) {
throw new UnauthorizedException();
}

const result = await this.metaTagExtractorService.fetchMetaData(url);
return result;
}
}

0 comments on commit e8fb31b

Please sign in to comment.