chore: add docker file for build
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { ApiProperty, PickType } from "@nestjs/swagger";
|
||||
import { IsEmail, IsNotEmpty, IsString } from "class-validator";
|
||||
|
||||
import { AuthMessage } from "../../../common/enums/message.enum";
|
||||
@@ -14,3 +14,5 @@ export class LoginPasswordDTO {
|
||||
@ApiProperty({ type: "string", description: "password user", example: "@1234" })
|
||||
password: string;
|
||||
}
|
||||
|
||||
export class CheckUserExistDto extends PickType(LoginPasswordDTO, ["email"] as const) {}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ApiOperation, ApiTags } from "@nestjs/swagger";
|
||||
import { Throttle, ThrottlerGuard } from "@nestjs/throttler";
|
||||
|
||||
import { CompleteRegistrationDto } from "./DTO/complete-register.dto";
|
||||
import { LoginPasswordDTO } from "./DTO/loginPassword.dto";
|
||||
import { CheckUserExistDto, LoginPasswordDTO } from "./DTO/loginPassword.dto";
|
||||
import { RequestOtpDto } from "./DTO/request-otp.dto";
|
||||
import { VerifyOtpDto } from "./DTO/verify-otp.dto";
|
||||
import { AuthService } from "./providers/auth.service";
|
||||
@@ -43,6 +43,13 @@ export class AuthController {
|
||||
return this.authService.verifyLoginOtp(verifyOtpDto);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: "check if user email exist" })
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post("check")
|
||||
checkUserExist(@Body() checkUserExistDto: CheckUserExistDto) {
|
||||
return this.authService.checkUserExist(checkUserExistDto);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: "login with password" })
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post("login/password")
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { BadRequestException, Injectable, Logger } from "@nestjs/common";
|
||||
|
||||
import { TokensService } from "./tokens.service";
|
||||
import { AuthMessage, UserMessage } from "../../../common/enums/message.enum";
|
||||
import { AuthMessage, CommonMessage, UserMessage } from "../../../common/enums/message.enum";
|
||||
import { UsersService } from "../../users/providers/users.service";
|
||||
import { OTPService } from "../../utils/providers/otp.service";
|
||||
import { PasswordService } from "../../utils/providers/password.service";
|
||||
import { CompleteRegistrationDto } from "../DTO/complete-register.dto";
|
||||
import { LoginPasswordDTO } from "../DTO/loginPassword.dto";
|
||||
import { CheckUserExistDto, LoginPasswordDTO } from "../DTO/loginPassword.dto";
|
||||
import { RequestOtpDto } from "../DTO/request-otp.dto";
|
||||
import { VerifyOtpDto } from "../DTO/verify-otp.dto";
|
||||
|
||||
@@ -77,6 +77,13 @@ export class AuthService {
|
||||
...tokens,
|
||||
};
|
||||
}
|
||||
//****************** */
|
||||
|
||||
async checkUserExist(checkUserExistDto: CheckUserExistDto) {
|
||||
const user = await this.usersService.findOneWithEmail(checkUserExistDto.email);
|
||||
if (!user) throw new BadRequestException(UserMessage.USER_NOT_FOUND);
|
||||
return { message: CommonMessage.USER_EXIST };
|
||||
}
|
||||
|
||||
//****************** */
|
||||
|
||||
|
||||
@@ -40,9 +40,8 @@ export class UsersService {
|
||||
}
|
||||
/************************************************************ */
|
||||
|
||||
async findOneWithEmail(email: string): Promise<User> {
|
||||
async findOneWithEmail(email: string): Promise<User | null> {
|
||||
const user = await this.userRepository.findOneWithEmail(email);
|
||||
if (!user) throw new BadRequestException(UserMessage.USER_NOT_FOUND);
|
||||
return user;
|
||||
}
|
||||
/************************************************************ */
|
||||
|
||||
Reference in New Issue
Block a user