feat: refactoring auth & add email password login (#318)

* feat: wip

* fix: issues

* feat: clean controllers and services

* fix: test

* Fix auth

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Jérémy M
2023-06-17 13:42:02 +02:00
committed by GitHub
parent d13ceb98fa
commit 299ca293a8
215 changed files with 1668 additions and 680 deletions

View File

@ -3,18 +3,22 @@ import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { JwtAuthStrategy } from './strategies/jwt.auth.strategy';
import { AuthService } from './services/auth.service';
import { GoogleAuthController } from './google.auth.controller';
import { GoogleAuthController } from './controllers/google-auth.controller';
import { GoogleStrategy } from './strategies/google.auth.strategy';
import { TokenController } from './token.controller';
import { TokenController } from './controllers/token.controller';
import { PrismaService } from 'src/database/prisma.service';
import { UserModule } from '../user/user.module';
import { AuthController } from './controllers/auth.controller';
import { PasswordAuthController } from './controllers/password-auth.controller';
import { TokenService } from './services/token.service';
const jwtModule = JwtModule.registerAsync({
useFactory: async (configService: ConfigService) => {
return {
secret: configService.get<string>('JWT_SECRET'),
secret: configService.get<string>('ACCESS_TOKEN_SECRET'),
signOptions: {
expiresIn: configService.get<string>('JWT_EXPIRES_IN') + 's',
expiresIn: configService.get<string>('ACCESS_TOKEN_EXPIRES_IN'),
},
};
},
@ -24,8 +28,19 @@ const jwtModule = JwtModule.registerAsync({
@Module({
imports: [jwtModule, ConfigModule.forRoot({}), UserModule],
controllers: [GoogleAuthController, TokenController],
providers: [AuthService, JwtAuthStrategy, GoogleStrategy, PrismaService],
controllers: [
GoogleAuthController,
PasswordAuthController,
TokenController,
AuthController,
],
providers: [
AuthService,
TokenService,
JwtAuthStrategy,
GoogleStrategy,
PrismaService,
],
exports: [jwtModule],
})
export class AuthModule {}