resetear password
This commit is contained in:
@@ -34,6 +34,12 @@ export class UsuarioController {
|
||||
return this.usuarioService.update(body);
|
||||
}
|
||||
|
||||
@Put('update-password')
|
||||
// @UseGuards(AuthGuard('jwt'))
|
||||
passwordResset(@Body() body: UsuarioUpdateDto) {
|
||||
return this.usuarioService.passwordReset(body.id_usuario);
|
||||
}
|
||||
|
||||
@Get('usuario')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
usuario(@Query() query: UsuarioDto) {
|
||||
|
||||
@@ -12,13 +12,13 @@ import { TipoUsuarioModule } from '../tipo-usuario/tipo-usuario.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
PassportModule.register({ defaultStrategy: 'jwt' }),
|
||||
TypeOrmModule.forFeature([Usuario]),
|
||||
BcryptModule,
|
||||
CarreraModule,
|
||||
InstitucionModule,
|
||||
NodemailerModule,
|
||||
PassportModule.register({ defaultStrategy: 'jwt' }),
|
||||
TipoUsuarioModule,
|
||||
TypeOrmModule.forFeature([Usuario]),
|
||||
],
|
||||
controllers: [UsuarioController],
|
||||
providers: [UsuarioService],
|
||||
|
||||
@@ -5,10 +5,10 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Usuario } from './entity/usuario.entity';
|
||||
import { Carrera } from '../carrera/entity/carrera.entity';
|
||||
import { Institucion } from '../institucion/entity/institucion.entity';
|
||||
import { TipoUsuario } from '../tipo-usuario/entity/tipo-usuario.entity';
|
||||
import { Usuario } from './entity/usuario.entity';
|
||||
import { BcryptService } from '../bcrypt/bcrypt.service';
|
||||
import { CarreraService } from '../carrera/carrera.service';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
@@ -45,8 +45,7 @@ export class UsuarioService {
|
||||
|
||||
<p>Atte.</p>
|
||||
|
||||
<p>Pc Puma Solicita</p>
|
||||
`;
|
||||
<p>Pc Puma Solicita</p>`;
|
||||
}
|
||||
|
||||
async findAll(filtros: {
|
||||
@@ -115,9 +114,15 @@ export class UsuarioService {
|
||||
if (!usuario.password)
|
||||
throw new ConflictException('No existe este usuario.');
|
||||
usuario.password = this.bcryptService.encriptar(password);
|
||||
/* Mandar correo con contraseña */
|
||||
return this.repository.save(usuario);
|
||||
})
|
||||
.then((usuario) =>
|
||||
this.nodemailerService.sendEmail({
|
||||
email: `${usuario.usuario}@pcpuma.acatlan.unam.mx`,
|
||||
subject: 'Credenciales Pc Puma',
|
||||
html: this.correoPassword(password),
|
||||
}),
|
||||
)
|
||||
.then((_) => ({
|
||||
message: 'Se reseteo correctamente la constraseña del usuario.',
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user