Commit b0dde758 authored by Diego Iván's avatar Diego Iván
Browse files

formateando archivos con nuevas reglas de prettier

parent 23d83137
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -6,9 +6,7 @@ import { InjectRepository } from '@nestjs/typeorm';

@Injectable()
export class AdminService {
  constructor(
    @InjectRepository(Admin) private adminRepository: Repository<Admin>,
  ) {}
  constructor(@InjectRepository(Admin) private adminRepository: Repository<Admin>) {}
  async create(createAdminDto: CreateAdminDto) {
    await this.adminRepository.insert(createAdminDto);
  }
+2 −8
Original line number Diff line number Diff line
@@ -2,12 +2,7 @@ import { Body, Controller, Post } from '@nestjs/common';
import { AuthAdminService } from './authAdminservice';
import { CreateAdminDto } from 'src/admin/dto/create-admin.dto';
import { LoginAdminDto } from 'src/auth/admin/dto/login-admin.dto';
import {
  ApiBody,
  ApiCreatedResponse,
  ApiTags,
  ApiUnauthorizedResponse,
} from '@nestjs/swagger';
import { ApiBody, ApiCreatedResponse, ApiTags, ApiUnauthorizedResponse } from '@nestjs/swagger';
import { AdminSigninResDto } from './dto/admin-signin-res.dto';

@Controller()
@@ -43,8 +38,7 @@ export class AuthAdminController {
  @Post('admin/signin')
  async signIn(@Body() loginAdminDto: LoginAdminDto) {
    try {
      const adminSigninResDto =
        await this.authAdminService.signIn(loginAdminDto);
      const adminSigninResDto = await this.authAdminService.signIn(loginAdminDto);
      return adminSigninResDto;
    } catch (e) {
      throw e;
+4 −13
Original line number Diff line number Diff line
@@ -22,30 +22,21 @@ export class AuthAdminService {
      email: createAdminDto.email,
      password: createAdminDto.password,
    };
    const hashedPwd = await this.encryptionService.hashPassword(
      createAdminDto.password,
    );
    const hashedPwd = await this.encryptionService.hashPassword(createAdminDto.password);
    createAdminDto.password = hashedPwd;
    await this.adminService.create(createAdminDto);

    const adminSigninResDto: AdminSigninResDto =
      await this.signIn(loginAdminDto);
    const adminSigninResDto: AdminSigninResDto = await this.signIn(loginAdminDto);
    return adminSigninResDto.token;
  }

  async signIn(logInAdmin: LoginAdminDto): Promise<AdminSigninResDto> {
    const admin: Admin = await this.adminService.findOne(logInAdmin.email);
    const validPwd: boolean = await this.encryptionService.comparePassword(
      logInAdmin.password,
      admin.password,
    );
    const validPwd: boolean = await this.encryptionService.comparePassword(logInAdmin.password, admin.password);
    if (!validPwd) {
      throw new HttpException('Invalid credentials', HttpStatus.UNAUTHORIZED);
    }
    const accessToken = await this.jwtService.sign(
      { email: admin.email },
      { secret: JwtConstants.SECRET },
    );
    const accessToken = await this.jwtService.sign({ email: admin.email }, { secret: JwtConstants.SECRET });
    const adminSigninResDto: AdminSigninResDto = {
      email: admin.email,
      name: admin.name,
+1 −4
Original line number Diff line number Diff line
@@ -8,10 +8,7 @@ export class EncryptionService {
    return hashedPwd;
  }

  async comparePassword(
    password: string,
    hashedPassword: string,
  ): Promise<boolean> {
  async comparePassword(password: string, hashedPassword: string): Promise<boolean> {
    return await bcrypt.compare(password, hashedPassword);
  }
}
+2 −9
Original line number Diff line number Diff line
import { Body, Controller, Post } from '@nestjs/common';
import {
  ApiBearerAuth,
  ApiBody,
  ApiCreatedResponse,
  ApiTags,
  ApiUnauthorizedResponse,
} from '@nestjs/swagger';
import { ApiBearerAuth, ApiBody, ApiCreatedResponse, ApiTags, ApiUnauthorizedResponse } from '@nestjs/swagger';
import { AuthUserService } from './authUserservice';
import { CreateUserDto } from 'src/user/dto/create-user.dto';
import { LoginUserDto } from './dto/login-user.dto';
@@ -24,8 +18,7 @@ export class AuthUserController {
  @Post('user/signup')
  async signUp(@Body() createAdminDto: CreateUserDto) {
    try {
      const adminSigninResDto =
        await this.authUserService.signUp(createAdminDto);
      const adminSigninResDto = await this.authUserService.signUp(createAdminDto);
      return { user: adminSigninResDto };
    } catch (e) {
      throw e;
Loading