add refresh token
This commit is contained in:
@@ -6,11 +6,11 @@ import {
|
||||
UseGuards,
|
||||
Req,
|
||||
} from '@nestjs/common';
|
||||
import AuthService from './auth.service';
|
||||
import { LoginRequestDto } from './dto/login-request.dto';
|
||||
import { JwtAuthGuard } from './jwt-auth.guard';
|
||||
import { JwtRefreshAuthGuard } from './jwt-refresh-auth.guard';
|
||||
import express from 'express';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
|
||||
@@ -2,23 +2,27 @@ import { Module } from '@nestjs/common';
|
||||
import { JwtModule } from '@nestjs/jwt';
|
||||
import { PassportModule } from '@nestjs/passport';
|
||||
import { UserModule } from '../user/user.module';
|
||||
import AuthService from './auth.service';
|
||||
import { AuthService } from './auth.service';
|
||||
import { AuthController } from './auth.controller';
|
||||
import { JwtStrategy } from './jwt.strategy';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { JwtRefreshTokenStrategy } from './jwt-refresh.strategy';
|
||||
import { StringValue } from 'ms';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule,
|
||||
UserModule,
|
||||
PassportModule,
|
||||
// Restore the correct async registration for JwtModule
|
||||
JwtModule.registerAsync({
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: (configService: ConfigService) => ({
|
||||
secret: configService.get<string>('JWT_SECRET'),
|
||||
signOptions: { expiresIn: '2m' },
|
||||
signOptions: {
|
||||
expiresIn: configService.get<StringValue>('JWT_EXPIRATION_TIME'),
|
||||
},
|
||||
}),
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -8,7 +8,7 @@ import { ConfigService } from '@nestjs/config';
|
||||
import type { StringValue } from 'ms';
|
||||
|
||||
@Injectable()
|
||||
class AuthService {
|
||||
export class AuthService {
|
||||
constructor(
|
||||
private userService: UserService,
|
||||
private jwtService: JwtService,
|
||||
@@ -109,5 +109,3 @@ class AuthService {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default AuthService;
|
||||
|
||||
Reference in New Issue
Block a user