fix(backend): fix extraction body values in permission controllers

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-05-04 13:52:37 +02:00
parent f87a7e1e69
commit a5e12b9ad0
4 changed files with 7 additions and 7 deletions

View file

@ -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<NotePermissionsDto> {
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<NoteDto> {
const owner = await this.userService.getUserByUsername(newOwner);
return await this.noteService.toNoteDto(

View file

@ -384,7 +384,7 @@ export class NotesController {
async changeOwner(
@RequestUser() user: User,
@RequestNote() note: Note,
@Body() newOwner: string,
@Body('newOwner') newOwner: string,
): Promise<NoteDto> {
const owner = await this.userService.getUserByUsername(newOwner);
return await this.noteService.toNoteDto(

View file

@ -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<NotePermissions> => {
export const setNoteOwner = async (noteId: string, newOwner: string): Promise<NotePermissions> => {
const response = await new PutApiRequestBuilder<NotePermissions, OwnerChangeDto>(
`notes/${noteId}/metadata/permissions/owner`
)
.withJsonBody({
owner
newOwner
})
.sendRequest()
return response.asParsedJsonObject()

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
export interface OwnerChangeDto {
owner: string
newOwner: string
}
export interface PermissionSetDto {