Added Simple Auth with JWT Tokens and Postgres #2

Merged
igorpropisnov merged 10 commits from feature/add-auth into main 2024-05-08 12:28:39 +02:00
2 changed files with 10 additions and 5 deletions
Showing only changes of commit b30985d92f - Show all commits

View File

@ -17,16 +17,20 @@ export class AuthController {
constructor(private readonly authService: AuthService) {} constructor(private readonly authService: AuthService) {}
@Public() @Public()
@Post('local/signup') @Post('signup')
@HttpCode(HttpStatus.CREATED) @HttpCode(HttpStatus.CREATED)
public async signup(@Body() userCredentials: UserCredentialsDto): Promise<Tokens> { public async signup(
@Body() userCredentials: UserCredentialsDto
): Promise<Tokens> {
return this.authService.signup(userCredentials); return this.authService.signup(userCredentials);
} }
@Public() @Public()
@Post('local/signin') @Post('signin')
@HttpCode(HttpStatus.OK) @HttpCode(HttpStatus.OK)
public async signin(@Body() userCredentials: UserCredentialsDto): Promise<Tokens> { public async signin(
@Body() userCredentials: UserCredentialsDto
): Promise<Tokens> {
return this.authService.signin(userCredentials); return this.authService.signin(userCredentials);
} }

View File

@ -1,4 +1,4 @@
import { IsEmail, IsNotEmpty, IsString } from 'class-validator'; import { IsEmail, IsNotEmpty, IsString, MinLength } from 'class-validator';
export class UserCredentialsDto { export class UserCredentialsDto {
@IsNotEmpty() @IsNotEmpty()
@ -7,5 +7,6 @@ export class UserCredentialsDto {
@IsNotEmpty() @IsNotEmpty()
@IsString() @IsString()
@MinLength(8)
public password: string; public password: string;
} }