validate token
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
import { AuthGuard } from './auth.guard';
|
||||
import { AuthService } from './auth.service';
|
||||
import { registerDto } from './dto/registerDto.dto';
|
||||
import { UserDto } from 'src/users/dto/userDto.dto';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
@@ -21,34 +22,44 @@ export class AuthController {
|
||||
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post('login')
|
||||
signIn(@Body() data: registerDto) {
|
||||
async signIn(@Body() data: registerDto) {
|
||||
return this.authService.signIn(data);
|
||||
}
|
||||
|
||||
@Post("register")
|
||||
async postRegister(@Body() data: registerDto){
|
||||
return this.authService.register(data)
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Get('profile')
|
||||
getProfile(@Request() req) {
|
||||
async getProfile(@Request() req) {
|
||||
return req.user;
|
||||
}
|
||||
|
||||
@Post("register")
|
||||
postRegister(@Body() data: registerDto){
|
||||
return this.authService.register(data)
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Post('Alta')
|
||||
async create(@Body() createUserDto: Record<string, any>) {
|
||||
return this.authService.create(createUserDto.username,createUserDto.password);
|
||||
async create(@Body() data: UserDto) {
|
||||
return this.authService.create(data);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Put('Modificacion/:id')
|
||||
async update(@Param('id') id: number, @Body() updateUserDto: Record<string, any>) {
|
||||
return this.authService.update(id, updateUserDto);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Delete('Borrado/:id')
|
||||
async remove(@Param('id') id: number) {
|
||||
await this.authService.remove(id);
|
||||
return { message: 'User successfully deleted' };
|
||||
}
|
||||
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post('validate')
|
||||
async validateToken(@Body('token') token: string) {
|
||||
return this.authService.validateToken(token);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user