Adiciona primeiras partes da autenticacao
This commit is contained in:
29
src/auth/auth.controller.ts
Normal file
29
src/auth/auth.controller.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user