forked from Ynov/ptitspas-ynov-back
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { Body, Controller, Post, UseGuards } from '@nestjs/common';
|
|
import { LoginDto } from '../user/dto/login.dto';
|
|
import { AuthService } from './auth.service';
|
|
import { Public } from 'src/common/decorators/public.decorator';
|
|
import { RegisterDto } from '../user/dto/register.dto';
|
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { AuthGuard } from 'src/common/guards/auth.guard';
|
|
|
|
@ApiTags('Authentification')
|
|
@Controller('auth')
|
|
export class AuthController {
|
|
constructor(private readonly authService: AuthService) {}
|
|
|
|
@Public()
|
|
@ApiOperation({ summary: 'Connexion' })
|
|
@Post('login')
|
|
async login(@Body() dto: LoginDto) {
|
|
return this.authService.login(dto);
|
|
}
|
|
|
|
@Post('register')
|
|
@ApiOperation({ summary: 'Inscription' })
|
|
async register(@Body() dto: RegisterDto) {
|
|
return this.authService.register(dto);
|
|
}
|
|
|
|
@Post('refresh')
|
|
@ApiOperation({ summary: 'Rafraichir les tokens' })
|
|
async refresh(@Body('refresh_token') refreshToken: string) {
|
|
return this.authService.refreshTokens(refreshToken);
|
|
}
|
|
|
|
// @Get('me')
|
|
// @UseGuards(AuthGuard)
|
|
// @ApiBearerAuth('access-token')
|
|
// @ApiOperation({ summary: "Recuperer le profil de l'utilisateur connecte"})
|
|
// getProfile(@Request() req) {
|
|
// return req.user;
|
|
// }
|
|
}
|