From ad730e094332359c610f15e5aa833c9700de19b4 Mon Sep 17 00:00:00 2001 From: n08i40k Date: Sun, 13 Oct 2024 18:02:52 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D1=88=D0=BB=D0=BE=D1=81?= =?UTF-8?q?=D1=8C=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D1=82=D1=8C=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8E=20SignInResDtoV1=20=D0=BD?= =?UTF-8?q?=D0=B0=20SignInResDtoV2=20=D0=B8=D0=B7-=D0=B7=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B5=D0=BF=D1=80=D0=BE=D0=B4=D1=83=D0=BC=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=BE=D0=B4=D0=B0=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auth/auth.controller.ts | 10 +++++----- src/dto/auth.dto.ts | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 505b542..dd401b3 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -27,7 +27,7 @@ import { UpdateTokenReqDto, UpdateTokenResDto, SignInResDtoV0, - SignInResDtoV1, + SignInResDtoV2, } from "../dto/auth.dto"; import { ResultDto } from "../utility/validation/class-validator.interceptor"; import { ScheduleService } from "../schedule/schedule.service"; @@ -43,7 +43,7 @@ export class AuthController { @ApiExtraModels(SignInReqDto) @ApiExtraModels(SignInResDtoV0) - @ApiExtraModels(SignInResDtoV1) + @ApiExtraModels(SignInResDtoV2) @ApiOperation({ summary: "Авторизация по логину и паролю", tags: ["auth"] }) @ApiBody({ schema: refs(SignInReqDto)[0] }) @ApiOkResponse({ @@ -52,18 +52,18 @@ export class AuthController { }) @ApiOkResponse({ description: "Авторизация прошла успешно", - schema: refs(SignInResDtoV1)[0], + schema: refs(SignInResDtoV2)[0], }) @ApiUnauthorizedResponse({ description: "Некорректное имя пользователя или пароль", }) - @ResultDto([SignInResDtoV0, SignInResDtoV1]) + @ResultDto([SignInResDtoV0, SignInResDtoV2]) @HttpCode(HttpStatus.OK) @Post("sign-in") async signIn( @Body() signInDto: SignInReqDto, @ResponseVersion() responseVersion: number, - ): Promise { + ): Promise { const data = await this.authService.signIn(signInDto); return SignInResDto.stripVersion(data, responseVersion); } diff --git a/src/dto/auth.dto.ts b/src/dto/auth.dto.ts index cb2dd6f..8990320 100644 --- a/src/dto/auth.dto.ts +++ b/src/dto/auth.dto.ts @@ -36,7 +36,7 @@ export class SignInResDtoV0 { accessToken: string; } -export class SignInResDtoV1 extends SignInResDtoV0 { +export class SignInResDtoV2 extends SignInResDtoV0 { @ApiProperty({ example: "ИС-214/23", description: "Группа", @@ -46,15 +46,16 @@ export class SignInResDtoV1 extends SignInResDtoV0 { group: string; } -export class SignInResDto extends SignInResDtoV1 { +export class SignInResDto extends SignInResDtoV2 { public static stripVersion( instance: SignInResDto, version: number, - ): SignInResDtoV0 | SignInResDtoV1 { + ): SignInResDtoV0 | SignInResDtoV2 { switch (version) { default: return instance; - case 0: { + case 0: + case 1: { return plainToClass(SignInResDtoV0, instanceToPlain(instance), { excludeExtraneousValues: true, });