From 1f853c0f0ccc93868c60d311ade97b19eb881305 Mon Sep 17 00:00:00 2001 From: Bastian Wagner Date: Sun, 25 Aug 2024 19:56:41 +0200 Subject: [PATCH] auth --- idp/src/auth/auth.module.ts | 11 ++++++++--- idp/src/users/users.service.ts | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/idp/src/auth/auth.module.ts b/idp/src/auth/auth.module.ts index 2adee86..6915b36 100644 --- a/idp/src/auth/auth.module.ts +++ b/idp/src/auth/auth.module.ts @@ -14,6 +14,7 @@ import { } from 'src/model/auth-code.entity'; import { LoggerModule } from 'src/core/logger.module'; import { SessionKey, SessionKeyRepository } from 'src/model/session-key.entity'; +import { ConfigModule, ConfigService } from '@nestjs/config'; @Module({ providers: [ @@ -26,9 +27,13 @@ import { SessionKey, SessionKeyRepository } from 'src/model/session-key.entity'; ], controllers: [AuthController], imports: [ - JwtModule.register({ - secret: 'SECRET_KEY', // Ändere dies zu einer Umgebungsvariablen in einer realen Anwendung - signOptions: { expiresIn: '15m' }, + JwtModule.registerAsync({ + imports: [ConfigModule], + inject: [ConfigService], + useFactory: async (config: ConfigService) => ({ + secret: config.get('JWT_SECRET'), + signOptions: { expiresIn: config.get('JWT_EXPIRES_IN') }, + }), }), NestjsFormDataModule, TypeOrmModule.forFeature([ diff --git a/idp/src/users/users.service.ts b/idp/src/users/users.service.ts index f0faddb..e9da1dd 100644 --- a/idp/src/users/users.service.ts +++ b/idp/src/users/users.service.ts @@ -150,7 +150,7 @@ export class UsersService { throw new HttpException('Invalid token', 401); } - this.tokenRepo.removeCode(token); + // this.tokenRepo.removeCode(token); const access_token = this.createAccessToken(user); const refresh_token = this.createRefreshToken(user);