30 lines
845 B
TypeScript
30 lines
845 B
TypeScript
import { Controller, Post, Body, HttpCode, HttpStatus } from '@nestjs/common';
|
|
|
|
import LoginResponseDto from './dto/loginResponse.dto';
|
|
|
|
import { AuthService } from './auth.service';
|
|
import { LoginDto } from './dto/login.dto';
|
|
|
|
@Controller('auth')
|
|
export class AuthController {
|
|
constructor(private readonly authService: AuthService) {}
|
|
|
|
@Post('login')
|
|
async login(@Body() loginDto: LoginDto): Promise<LoginResponseDto> {
|
|
return this.authService.login(loginDto);
|
|
}
|
|
|
|
@Post('logout')
|
|
@HttpCode(HttpStatus.OK)
|
|
async logout(@Body() body: { refreshToken: string }): Promise<void> {
|
|
return this.authService.logout(body.refreshToken);
|
|
}
|
|
|
|
@Post('refresh-token')
|
|
async refreshToken(
|
|
@Body() body: { refreshToken: string },
|
|
): Promise<LoginResponseDto> {
|
|
return this.authService.refreshToken(body.refreshToken);
|
|
}
|
|
}
|