Spaces:
Sleeping
Sleeping
| // src/modules/auth/auth.module.ts | |
| // Updated to import EmailModule | |
| import { Module } from '@nestjs/common'; | |
| import { TypeOrmModule } from '@nestjs/typeorm'; | |
| import { JwtModule } from '@nestjs/jwt'; | |
| import { PassportModule } from '@nestjs/passport'; | |
| import { ConfigModule, ConfigService } from '@nestjs/config'; | |
| import { AuthController } from './auth.controller'; | |
| import { AuthService } from './auth.service'; | |
| import { UserManagementController } from './user-management.controller'; | |
| import { UserManagementService } from './user-management.service'; | |
| import { UserProfileController } from './user-profile.controller'; | |
| import { User } from './entities/user.entity'; | |
| import { Role } from './entities/role.entity'; | |
| import { Permission } from './entities/permission.entity'; | |
| import { Session } from './entities/session.entity'; | |
| import { PasswordReset } from './entities/password-reset.entity'; | |
| import { TwoFactorAuth } from './entities/two-factor-auth.entity'; | |
| import { UserPreference } from './entities/user-preference.entity'; | |
| import { JwtStrategy } from './strategies/jwt.strategy'; | |
| import { EmailModule } from '../email/email.module'; | |
| import { SecurityModule } from '../security/security.module'; | |
| import { AdminDashboardService } from './admin-dashboard.service'; | |
| import { NotificationsModule } from '../notifications/notifications.module'; | |
| ({ | |
| imports: [ | |
| TypeOrmModule.forFeature([ | |
| User, | |
| Role, | |
| Permission, | |
| Session, | |
| PasswordReset, | |
| TwoFactorAuth, | |
| UserPreference, | |
| ]), | |
| PassportModule.register({ defaultStrategy: 'jwt' }), | |
| JwtModule.registerAsync({ | |
| imports: [ConfigModule], | |
| inject: [ConfigService], | |
| useFactory: async (configService: ConfigService) => { | |
| const secret = configService.get<string>('JWT_SECRET'); | |
| const expiresIn = configService.get('JWT_EXPIRATION', '1h'); | |
| if (!secret) { | |
| throw new Error('JWT_SECRET environment variable is required'); | |
| } | |
| return { | |
| secret, | |
| signOptions: { | |
| expiresIn: expiresIn as any, | |
| }, | |
| }; | |
| }, | |
| }), | |
| EmailModule, | |
| SecurityModule, | |
| NotificationsModule, | |
| ], | |
| controllers: [AuthController, UserManagementController, UserProfileController], | |
| providers: [AuthService, UserManagementService, AdminDashboardService, JwtStrategy], | |
| exports: [AuthService, UserManagementService], | |
| }) | |
| export class AuthModule {} | |