mirror of
https://github.com/n08i40k/schedule-parser-next.git
synced 2025-12-06 17:57:45 +03:00
Пред-деплой
This commit is contained in:
@@ -23,11 +23,13 @@ import {
|
||||
SignInResDto,
|
||||
SignUpReqDto,
|
||||
SignUpResDto,
|
||||
UpdateTokenDto,
|
||||
UpdateTokenResultDto,
|
||||
ChangePasswordReqDto,
|
||||
UpdateTokenReqDto,
|
||||
UpdateTokenResDto,
|
||||
} from "../dto/auth.dto";
|
||||
import { ResultDto } from "../utility/validation/class-validator.interceptor";
|
||||
import { ScheduleService } from "../schedule/schedule.service";
|
||||
import { UserToken } from "./auth.decorator";
|
||||
|
||||
@Controller("api/v1/auth")
|
||||
export class AuthController {
|
||||
@@ -82,26 +84,52 @@ export class AuthController {
|
||||
return this.authService.signUp(signUpDto);
|
||||
}
|
||||
|
||||
@ApiExtraModels(UpdateTokenDto)
|
||||
@ApiExtraModels(UpdateTokenResultDto)
|
||||
@ApiExtraModels(UpdateTokenReqDto)
|
||||
@ApiExtraModels(UpdateTokenResDto)
|
||||
@ApiOperation({
|
||||
summary: "Обновление просроченного токена",
|
||||
tags: ["auth"],
|
||||
tags: ["auth", "accessToken"],
|
||||
})
|
||||
@ApiBody({ schema: refs(UpdateTokenDto)[0] })
|
||||
@ApiBody({ schema: refs(UpdateTokenReqDto)[0] })
|
||||
@ApiOkResponse({
|
||||
description: "Токен обновлён успешно",
|
||||
schema: refs(UpdateTokenResultDto)[0],
|
||||
schema: refs(UpdateTokenResDto)[0],
|
||||
})
|
||||
@ApiNotFoundResponse({
|
||||
description: "Передан несуществующий или недействительный токен",
|
||||
})
|
||||
@ResultDto(UpdateTokenResultDto)
|
||||
@ResultDto(UpdateTokenResDto)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post("updateToken")
|
||||
updateToken(
|
||||
@Body() updateTokenDto: UpdateTokenDto,
|
||||
): Promise<UpdateTokenResultDto> {
|
||||
@Body() updateTokenDto: UpdateTokenReqDto,
|
||||
): Promise<UpdateTokenResDto> {
|
||||
return this.authService.updateToken(updateTokenDto);
|
||||
}
|
||||
|
||||
@ApiExtraModels(ChangePasswordReqDto)
|
||||
@ApiOperation({
|
||||
summary: "Обновление пароля",
|
||||
tags: ["auth", "password"],
|
||||
})
|
||||
@ApiBody({ schema: refs(ChangePasswordReqDto)[0] })
|
||||
@ApiOkResponse({ description: "Пароль обновлён успешно" })
|
||||
@ApiConflictResponse({ description: "Пароли идентичны" })
|
||||
@ApiUnauthorizedResponse({
|
||||
description:
|
||||
"Передан неверный текущий пароль или запрос был послан без токена",
|
||||
})
|
||||
@ResultDto(null)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post("changePassword")
|
||||
async changePassword(
|
||||
@Body() changePasswordReqDto: ChangePasswordReqDto,
|
||||
@UserToken() userToken: string,
|
||||
): Promise<void> {
|
||||
await this.authService
|
||||
.decodeUserToken(userToken)
|
||||
.then((user) =>
|
||||
this.authService.changePassword(user, changePasswordReqDto),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user