forked from Yara724/api
YARA-1035
This commit is contained in:
32
src/features/expert-initiated/expert-initiated.service.ts
Normal file
32
src/features/expert-initiated/expert-initiated.service.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user