From fc7b8f4c16cef0e72b04f096d5a17d4144b5feb7 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Fri, 15 Jan 2021 22:43:22 +0100 Subject: [PATCH] Updated descriptions and responses ref #100 --- src/controllers/MeController.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/controllers/MeController.ts b/src/controllers/MeController.ts index bcdb48b..a9ff4ac 100644 --- a/src/controllers/MeController.ts +++ b/src/controllers/MeController.ts @@ -4,7 +4,6 @@ import { getConnectionManager, Repository } from 'typeorm'; import { UserDeletionNotConfirmedError, UserIdsNotMatchingError, UsernameContainsIllegalCharacterError, UserNotFoundError } from '../errors/UserErrors'; import { UpdateUser } from '../models/actions/update/UpdateUser'; import { User } from '../models/entities/User'; -import { ResponseEmpty } from '../models/responses/ResponseEmpty'; import { ResponseUser } from '../models/responses/ResponseUser'; import { ResponseUserPermissions } from '../models/responses/ResponseUserPermissions'; import { PermissionController } from './PermissionController'; @@ -68,13 +67,12 @@ export class MeController { @Delete('/') @ResponseSchema(ResponseUser) - @ResponseSchema(ResponseEmpty, { statusCode: 204 }) + @ResponseSchema(UserNotFoundError, { statusCode: 404 }) @ResponseSchema(UserDeletionNotConfirmedError, { statusCode: 406 }) - @OnUndefined(204) - @OpenAPI({ description: 'Delete the user whose id you provided.
If there are any permissions directly granted to the user they will get deleted as well.
If no user with this id exists it will just return 204(no content).' }) + @OpenAPI({ description: 'Delete yourself.
You have to confirm your decision by providing the ?force=true query param.
If there are any permissions directly granted to you they will get deleted as well.' }) async remove(@CurrentUser() currentUser: User, @QueryParam("force") force: boolean) { if (!force) { throw new UserDeletionNotConfirmedError; } - if (!currentUser) { return null; } + if (!currentUser) { return UserNotFoundError; } const responseUser = await this.userRepository.findOne({ id: currentUser.id }, { relations: ['permissions', 'groups', 'groups.permissions'] });; const permissionControler = new PermissionController();