auth
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
|||||||
} from 'src/model/auth-code.entity';
|
} from 'src/model/auth-code.entity';
|
||||||
import { LoggerModule } from 'src/core/logger.module';
|
import { LoggerModule } from 'src/core/logger.module';
|
||||||
import { SessionKey, SessionKeyRepository } from 'src/model/session-key.entity';
|
import { SessionKey, SessionKeyRepository } from 'src/model/session-key.entity';
|
||||||
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
providers: [
|
providers: [
|
||||||
@@ -26,9 +27,13 @@ import { SessionKey, SessionKeyRepository } from 'src/model/session-key.entity';
|
|||||||
],
|
],
|
||||||
controllers: [AuthController],
|
controllers: [AuthController],
|
||||||
imports: [
|
imports: [
|
||||||
JwtModule.register({
|
JwtModule.registerAsync({
|
||||||
secret: 'SECRET_KEY', // Ändere dies zu einer Umgebungsvariablen in einer realen Anwendung
|
imports: [ConfigModule],
|
||||||
signOptions: { expiresIn: '15m' },
|
inject: [ConfigService],
|
||||||
|
useFactory: async (config: ConfigService) => ({
|
||||||
|
secret: config.get('JWT_SECRET'),
|
||||||
|
signOptions: { expiresIn: config.get('JWT_EXPIRES_IN') },
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
NestjsFormDataModule,
|
NestjsFormDataModule,
|
||||||
TypeOrmModule.forFeature([
|
TypeOrmModule.forFeature([
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ export class UsersService {
|
|||||||
throw new HttpException('Invalid token', 401);
|
throw new HttpException('Invalid token', 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.tokenRepo.removeCode(token);
|
// this.tokenRepo.removeCode(token);
|
||||||
|
|
||||||
const access_token = this.createAccessToken(user);
|
const access_token = this.createAccessToken(user);
|
||||||
const refresh_token = this.createRefreshToken(user);
|
const refresh_token = this.createRefreshToken(user);
|
||||||
|
|||||||
Reference in New Issue
Block a user