From a5e12b9ad011b8baf9012c4784b69d58a24f575e Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Thu, 4 May 2023 13:52:37 +0200 Subject: [PATCH] fix(backend): fix extraction body values in permission controllers Signed-off-by: Tilman Vatteroth --- backend/src/api/private/notes/notes.controller.ts | 4 ++-- backend/src/api/public/notes/notes.controller.ts | 2 +- frontend/src/api/permissions/index.ts | 6 +++--- frontend/src/api/permissions/types.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/src/api/private/notes/notes.controller.ts b/backend/src/api/private/notes/notes.controller.ts index 1a27c7342..1286b983a 100644 --- a/backend/src/api/private/notes/notes.controller.ts +++ b/backend/src/api/private/notes/notes.controller.ts @@ -205,7 +205,7 @@ export class NotesController { @RequestUser() user: User, @RequestNote() note: Note, @Param('userName') username: string, - @Body() canEdit: boolean, + @Body('canEdit') canEdit: boolean, ): Promise { const permissionUser = await this.userService.getUserByUsername(username); const returnedNote = await this.permissionService.setUserPermission( @@ -285,7 +285,7 @@ export class NotesController { async changeOwner( @RequestUser() user: User, @RequestNote() note: Note, - @Body() newOwner: string, + @Body('newOwner') newOwner: string, ): Promise { const owner = await this.userService.getUserByUsername(newOwner); return await this.noteService.toNoteDto( diff --git a/backend/src/api/public/notes/notes.controller.ts b/backend/src/api/public/notes/notes.controller.ts index c904518ad..c98f6d2a6 100644 --- a/backend/src/api/public/notes/notes.controller.ts +++ b/backend/src/api/public/notes/notes.controller.ts @@ -384,7 +384,7 @@ export class NotesController { async changeOwner( @RequestUser() user: User, @RequestNote() note: Note, - @Body() newOwner: string, + @Body('newOwner') newOwner: string, ): Promise { const owner = await this.userService.getUserByUsername(newOwner); return await this.noteService.toNoteDto( diff --git a/frontend/src/api/permissions/index.ts b/frontend/src/api/permissions/index.ts index dcb1a3c14..0c3c7c17d 100644 --- a/frontend/src/api/permissions/index.ts +++ b/frontend/src/api/permissions/index.ts @@ -12,16 +12,16 @@ import type { NotePermissions } from '@hedgedoc/commons' * Sets the owner of a note. * * @param noteId The id of the note. - * @param owner The username of the new owner. + * @param newOwner The username of the new owner. * @return The updated {@link NotePermissions}. * @throws {Error} when the api request wasn't successful. */ -export const setNoteOwner = async (noteId: string, owner: string): Promise => { +export const setNoteOwner = async (noteId: string, newOwner: string): Promise => { const response = await new PutApiRequestBuilder( `notes/${noteId}/metadata/permissions/owner` ) .withJsonBody({ - owner + newOwner }) .sendRequest() return response.asParsedJsonObject() diff --git a/frontend/src/api/permissions/types.ts b/frontend/src/api/permissions/types.ts index da505c956..36e966a7b 100644 --- a/frontend/src/api/permissions/types.ts +++ b/frontend/src/api/permissions/types.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ export interface OwnerChangeDto { - owner: string + newOwner: string } export interface PermissionSetDto {