29 lines
1023 B
TypeScript
29 lines
1023 B
TypeScript
import {
|
|
MiddlewareConsumer,
|
|
Module,
|
|
NestModule,
|
|
RequestMethod,
|
|
} from '@nestjs/common';
|
|
import { CSRFMiddleware } from 'src/middleware/csrf.middleware';
|
|
import { FlashMiddleware } from 'src/middleware/flash.middleware';
|
|
import { UserMiddleware } from 'src/middleware/user.middleware';
|
|
import { ValidateCSRFMiddleware } from 'src/middleware/validate-csrf.middleware';
|
|
import { UserTokenModule } from 'src/modules/objects/user-token/user-token.module';
|
|
import { UserModule } from 'src/modules/objects/user/user.module';
|
|
import { LoginController } from './login.controller';
|
|
|
|
@Module({
|
|
imports: [UserModule, UserTokenModule],
|
|
controllers: [LoginController],
|
|
})
|
|
export class LoginModule implements NestModule {
|
|
configure(consumer: MiddlewareConsumer) {
|
|
consumer.apply(CSRFMiddleware, UserMiddleware).forRoutes(LoginController);
|
|
consumer
|
|
.apply(ValidateCSRFMiddleware)
|
|
.forRoutes({ path: 'login*', method: RequestMethod.POST });
|
|
|
|
consumer.apply(FlashMiddleware).forRoutes('login*');
|
|
}
|
|
}
|