feat: Basic setup with auth
This commit is contained in:
@@ -1 +1,3 @@
|
||||
export * from './register-user.dto';
|
||||
export * from './login-user.dto';
|
||||
export * from './login-response.dto';
|
||||
|
||||
14
src/auth/dto/login-response.dto.ts
Normal file
14
src/auth/dto/login-response.dto.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { User } from 'prisma/generated/prisma/client';
|
||||
import { UserDTO } from 'src/user/dtos';
|
||||
|
||||
export class LoginUserResponseDTO {
|
||||
readonly accessToken: string;
|
||||
readonly refreshToken: string;
|
||||
readonly user: UserDTO;
|
||||
|
||||
constructor(user: User, accessToken: string, refreshToken: string) {
|
||||
this.user = new UserDTO(user);
|
||||
this.accessToken = accessToken;
|
||||
this.refreshToken = refreshToken;
|
||||
}
|
||||
}
|
||||
24
src/auth/dto/login-user.dto.ts
Normal file
24
src/auth/dto/login-user.dto.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsEmail, IsNotEmpty, IsString, MinLength } from 'class-validator';
|
||||
|
||||
export class LoginUserRequestDTO {
|
||||
@ApiProperty({
|
||||
description: "User's email",
|
||||
example: 'user@example.com',
|
||||
type: 'string',
|
||||
})
|
||||
@IsEmail()
|
||||
@IsNotEmpty()
|
||||
email: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: "User's password",
|
||||
example: '123456',
|
||||
type: 'string',
|
||||
minLength: 6,
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MinLength(6)
|
||||
password: string;
|
||||
}
|
||||
Reference in New Issue
Block a user