This repository has been archived on 2024-06-14. You can view files and clone it, but cannot push or open issues or pull requests.
icynet-auth-server/src/modules/static-front-end/login/login.module.ts

29 lines
1023 B
TypeScript
Raw Normal View History

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';
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({
imports: [UserModule, UserTokenModule],
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)
.forRoutes({ path: 'login*', method: RequestMethod.POST });
2022-03-09 21:10:08 +00:00
consumer.apply(FlashMiddleware).forRoutes('login*');
2022-03-09 18:37:04 +00:00
}
}