2022-03-09 18:37:04 +00:00
|
|
|
import {
|
|
|
|
MiddlewareConsumer,
|
|
|
|
Module,
|
|
|
|
NestModule,
|
|
|
|
RequestMethod,
|
|
|
|
} from '@nestjs/common';
|
2022-09-01 17:19:08 +00:00
|
|
|
import { CSRFMiddleware } from 'src/middleware/csrf.middleware';
|
2022-03-09 21:10:08 +00:00
|
|
|
import { FlashMiddleware } from 'src/middleware/flash.middleware';
|
2022-09-01 17:19:08 +00:00
|
|
|
import { UserMiddleware } from 'src/middleware/user.middleware';
|
2022-03-09 18:37:04 +00:00
|
|
|
import { ValidateCSRFMiddleware } from 'src/middleware/validate-csrf.middleware';
|
2022-09-09 17:12:22 +00:00
|
|
|
import { AuditModule } from 'src/modules/objects/audit/audit.module';
|
2022-03-15 17:00:15 +00:00
|
|
|
import { UserTokenModule } from 'src/modules/objects/user-token/user-token.module';
|
2022-03-09 18:37:04 +00:00
|
|
|
import { UserModule } from 'src/modules/objects/user/user.module';
|
|
|
|
import { LoginController } from './login.controller';
|
|
|
|
|
|
|
|
@Module({
|
2022-09-09 17:12:22 +00:00
|
|
|
imports: [UserModule, UserTokenModule, AuditModule],
|
2022-03-09 18:37:04 +00:00
|
|
|
controllers: [LoginController],
|
|
|
|
})
|
|
|
|
export class LoginModule implements NestModule {
|
|
|
|
configure(consumer: MiddlewareConsumer) {
|
2022-09-01 17:19:08 +00:00
|
|
|
consumer.apply(CSRFMiddleware, UserMiddleware).forRoutes(LoginController);
|
2022-03-09 18:37:04 +00:00
|
|
|
consumer
|
|
|
|
.apply(ValidateCSRFMiddleware)
|
2022-03-19 10:25:37 +00:00
|
|
|
.forRoutes({ path: 'login*', method: RequestMethod.POST });
|
2022-03-09 21:10:08 +00:00
|
|
|
|
2022-03-19 10:25:37 +00:00
|
|
|
consumer.apply(FlashMiddleware).forRoutes('login*');
|
2022-03-09 18:37:04 +00:00
|
|
|
}
|
|
|
|
}
|