summaryrefslogtreecommitdiff
path: root/server/app.module.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/app.module.ts')
-rw-r--r--server/app.module.ts13
1 files changed, 12 insertions, 1 deletions
diff --git a/server/app.module.ts b/server/app.module.ts
index e82aa66..41446f8 100644
--- a/server/app.module.ts
+++ b/server/app.module.ts
@@ -1,13 +1,24 @@
import { Module } from '@nestjs/common';
+import { APP_GUARD } from '@nestjs/core';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AppController } from './app.controller';
import { config } from './database/config';
import { UsersModule } from './modules/users.module';
+import { AuthGuard } from './providers/guards/auth.guard';
+import { RolesGuard } from './providers/guards/roles.guard';
import { JwtService } from './providers/services/jwt.service';
+import { RolesService } from './providers/services/roles.service';
+import { UsersService } from './providers/services/users.service';
@Module({
imports: [TypeOrmModule.forRoot(config), UsersModule],
controllers: [AppController],
- providers: [JwtService],
+ providers: [
+ UsersService,
+ RolesService,
+ JwtService,
+ { provide: APP_GUARD, useClass: AuthGuard }, // auth guard should come before roles guard
+ { provide: APP_GUARD, useClass: RolesGuard }, // otherwise users won't be authenticated before roles check
+ ],
})
export class AppModule {}