From 30048aa544773ac2c8fe489d8a455877b6af03cd Mon Sep 17 00:00:00 2001 From: IO <320154041@pcpuma.acatlan.unam.mx> Date: Tue, 18 Jun 2024 16:38:34 -0600 Subject: [PATCH] fixed bug --- src/Profesor/profesor.controller.ts | 1 - src/auth/auth.controller.ts | 7 +------ src/auth/auth.service.ts | 2 -- src/auth/dto/registerDto.dto.ts | 4 ++-- src/users/dto/userDto.dto.ts | 10 +++++++++- src/users/users.service.ts | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Profesor/profesor.controller.ts b/src/Profesor/profesor.controller.ts index 3cf47d1..85aa4fd 100644 --- a/src/Profesor/profesor.controller.ts +++ b/src/Profesor/profesor.controller.ts @@ -1,7 +1,6 @@ import { Body, Controller, Delete, Get, Param, ParseIntPipe, Post, Put } from '@nestjs/common'; import { ProfesorService } from './profesor.service'; import { profesorDto } from './dto/profesorDto.dto'; -import { ProfesorFilterDto } from './dto/profesorFilterDto.dto'; @Controller('profesor') export class ProfesorController { diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 0e72522..6a5f60d 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -26,6 +26,7 @@ export class AuthController { return this.authService.signIn(data); } + @UseGuards(AuthGuard) @Post("register") async register(@Body() data: registerDto){ return this.authService.register(data) @@ -37,12 +38,6 @@ export class AuthController { return req.user; } - @UseGuards(AuthGuard) - @Post('Alta') - async create(@Body() data: UserDto) { - return this.authService.create(data); - } - @UseGuards(AuthGuard) @Put('Modificacion/:id') async update(@Param('id') id: number, @Body() updateUserDto: Record) { diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index b020240..a147f0e 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -65,8 +65,6 @@ export class AuthService { return { token: token }; } - async create(data) {} - async update(id, updateUserDto) {} async remove(id) {} diff --git a/src/auth/dto/registerDto.dto.ts b/src/auth/dto/registerDto.dto.ts index 597b033..bf922d1 100644 --- a/src/auth/dto/registerDto.dto.ts +++ b/src/auth/dto/registerDto.dto.ts @@ -1,4 +1,4 @@ -import {IsString, IsNotEmpty,IsNumber } from "class-validator"; +import {IsString, IsNotEmpty,IsNumber,IsEmail } from "class-validator"; export class registerDto{ @@ -14,7 +14,7 @@ export class registerDto{ @IsNotEmpty() id_tipo_usuario:number; - @IsString() + @IsEmail() @IsNotEmpty() correo: string; diff --git a/src/users/dto/userDto.dto.ts b/src/users/dto/userDto.dto.ts index 0f1ba81..54d8644 100644 --- a/src/users/dto/userDto.dto.ts +++ b/src/users/dto/userDto.dto.ts @@ -1,4 +1,4 @@ -import { IsEmail, IsNotEmpty, IsString} from "class-validator"; +import { IsEmail, IsNotEmpty, IsString,IsNumber} from "class-validator"; export class UserDto{ @IsString() @@ -9,4 +9,12 @@ export class UserDto{ @IsNotEmpty() contraseƱa: string; + @IsNumber() + @IsNotEmpty() + id_tipo_usuario:number; + + @IsEmail() + @IsNotEmpty() + correo: string; + } \ No newline at end of file diff --git a/src/users/users.service.ts b/src/users/users.service.ts index 107753a..bf6736b 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -19,10 +19,10 @@ export class UsersService { const newUser = this.users.create(user); return this.users.save(newUser); } - //TODO Validar Esta funcion - // async update(userId: number, updateUserDto: UserDto): Promise { - // return await this.users.update(userId, updateUserDto); - // } + + //async update(userId: number, updateUserDto: UserDto): Promise { + //return await this.users.update(userId, updateUserDto); + //} async remove(userId: number): Promise { await this.users.delete(userId);