Spaces:
Sleeping
Sleeping
File size: 2,433 Bytes
1ddaa18 a38b26a 420a05a f183c60 a38b26a f183c60 a38b26a 4ca852f 2494e74 a8a7b69 a38b26a f183c60 a38b26a 1ddaa18 a38b26a 4ca852f 2494e74 a8a7b69 a38b26a f183c60 2494e74 420a05a a38b26a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | // 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';
@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 {}
|