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, });