base con autenticacion, registro, modulo encuestas
This commit is contained in:
61
apps/api/src/features/auth/auth.controller.ts
Normal file
61
apps/api/src/features/auth/auth.controller.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { Public } from '@/common/decorators';
|
||||
import { JwtRefreshGuard } from '@/common/guards/jwt-refresh.guard';
|
||||
import { RefreshTokenDto } from '@/features/auth/dto/refresh-token.dto';
|
||||
import { SignInUserDto } from '@/features/auth/dto/signIn-user.dto';
|
||||
import { SingUpUserDto } from '@/features/auth/dto/signUp-user.dto';
|
||||
import { SignOutUserDto } from '@/features/auth/dto/signOut-user.dto';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
HttpCode,
|
||||
Patch,
|
||||
Post,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { AuthService } from './auth.service';
|
||||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
constructor(private readonly authService: AuthService) {}
|
||||
|
||||
@Public()
|
||||
@HttpCode(200)
|
||||
@Post('sing-up')
|
||||
// @ApiOperation({ summary: 'Create a new user' })
|
||||
// @ApiResponse({ status: 201, description: 'User created successfully.' })
|
||||
async singUp(@Body() payload: SingUpUserDto) {
|
||||
const data = await this.authService.singUp(payload)
|
||||
return { message: 'User created successfully', data};
|
||||
// return { message: 'User created successfully', data };
|
||||
}
|
||||
|
||||
@Public()
|
||||
@HttpCode(200)
|
||||
@Post('sign-in')
|
||||
async signIn(@Body() signInUserDto: SignInUserDto) {
|
||||
return await this.authService.signIn(signInUserDto);
|
||||
}
|
||||
|
||||
@Post('sign-out')
|
||||
//@RequirePermissions('auth:sign-out')
|
||||
async signOut(@Body() signOutUserDto: SignOutUserDto) {
|
||||
await this.authService.signOut(signOutUserDto);
|
||||
return { message: 'User signed out successfully' };
|
||||
}
|
||||
|
||||
// @Post('forgot-password')
|
||||
// async forgotPassword(@Body() forgotPasswordDto: ForgotPasswordDto) {
|
||||
// await this.authService.forgotPassword(forgotPasswordDto);
|
||||
// return { message: 'Password reset link sent to your email' };
|
||||
// }
|
||||
|
||||
@UseGuards(JwtRefreshGuard)
|
||||
@Patch('refresh-token')
|
||||
//@RequirePermissions('auth:refresh-token')
|
||||
async refreshToken(@Body() refreshTokenDto: RefreshTokenDto) {
|
||||
return await this.authService.refreshToken(refreshTokenDto);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user