From ed994c55b61fa3e44f15ccaa2efa3c2a06eb8bb4 Mon Sep 17 00:00:00 2001 From: belhajManel Date: Tue, 30 Apr 2024 14:55:03 +0100 Subject: [PATCH] fix authentication guards and modules --- back/frankme/src/links/links.controller.ts | 3 +++ back/frankme/src/links/links.module.ts | 11 +---------- back/frankme/src/users/users.module.ts | 8 ++++---- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/back/frankme/src/links/links.controller.ts b/back/frankme/src/links/links.controller.ts index f2e3ed8..728756d 100644 --- a/back/frankme/src/links/links.controller.ts +++ b/back/frankme/src/links/links.controller.ts @@ -6,6 +6,7 @@ import { Patch, Param, Delete, + UseGuards, } from '@nestjs/common'; import { LinksService } from './links.service'; import { CreateLinkDto } from './dto/create-link.dto'; @@ -14,7 +15,9 @@ import { ActiveUser } from 'src/iam/authentication/decorators/active-user.decora import { AuthType } from 'src/iam/authentication/enums/auth-type.enum'; import { Auth } from 'src/iam/authentication/decorators/auth.decorator'; import { ActiveUserData } from 'src/iam/interfaces/active-user-data.interface'; +import { AccessTokenGuard } from 'src/iam/authentication/guards/access-token.guard'; +@UseGuards(AccessTokenGuard) @Auth(AuthType.Bearer) @Controller('links') export class LinksController { diff --git a/back/frankme/src/links/links.module.ts b/back/frankme/src/links/links.module.ts index 5ae3017..629aa7a 100644 --- a/back/frankme/src/links/links.module.ts +++ b/back/frankme/src/links/links.module.ts @@ -6,8 +6,6 @@ import { Link } from './entities/link.entity'; import { ConfigModule } from '@nestjs/config'; import { JwtModule } from '@nestjs/jwt'; import jwtConfig from 'src/iam/config/jwt.config'; -import { APP_GUARD } from '@nestjs/core'; -import { AccessTokenGuard } from 'src/iam/authentication/guards/access-token.guard'; import { UsersService } from 'src/users/users.service'; import { User } from 'src/users/entities/user.entity'; @@ -18,13 +16,6 @@ import { User } from 'src/users/entities/user.entity'; ConfigModule.forFeature(jwtConfig), ], controllers: [LinksController], - providers: [ - LinksService, - UsersService, - { - provide: APP_GUARD, - useClass: AccessTokenGuard, - }, - ], + providers: [LinksService, UsersService], }) export class LinksModule {} diff --git a/back/frankme/src/users/users.module.ts b/back/frankme/src/users/users.module.ts index 0af4f74..d0c01f7 100644 --- a/back/frankme/src/users/users.module.ts +++ b/back/frankme/src/users/users.module.ts @@ -18,10 +18,10 @@ import { APP_GUARD } from '@nestjs/core'; controllers: [UsersController], providers: [ UsersService, - { - provide: APP_GUARD, - useClass: AccessTokenGuard, - }, + // { + // provide: APP_GUARD, + // useClass: AccessTokenGuard, + // }, ], exports: [UsersService], })