Adiciona primeiras partes da autenticacao

This commit is contained in:
LeoMortari
2025-09-11 17:51:28 -03:00
parent 85aac808e9
commit ee1e3bd7f8
11 changed files with 228 additions and 6 deletions

View File

@@ -0,0 +1,29 @@
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);
}
}