import { BadRequestException, Injectable, NotFoundException, } from "@nestjs/common"; import { FieldExpertRepository } from "./repositories/field-expert.repository"; import { FieldExpertLoginDto } from "./dtos/login.dto"; import { UserAuthService } from "src/auth/auth-services/user.auth.service"; @Injectable() export class FieldExpertService { constructor( private readonly fieldExpertRepository: FieldExpertRepository, private readonly authService: UserAuthService, ) {} async login(fieldExpertLoginDto: FieldExpertLoginDto) { const user = await this.fieldExpertRepository.retrieveByEmail( fieldExpertLoginDto.email, ); if (!user) throw new NotFoundException("User not found"); const validate = await this.authService.validateUser( user.email, user.password, ); if (!validate) throw new BadRequestException("Username/Password does not match"); } }