mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
fix(backend): fix extraction body values in permission controllers
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
f87a7e1e69
commit
a5e12b9ad0
4 changed files with 7 additions and 7 deletions
|
@ -205,7 +205,7 @@ export class NotesController {
|
||||||
@RequestUser() user: User,
|
@RequestUser() user: User,
|
||||||
@RequestNote() note: Note,
|
@RequestNote() note: Note,
|
||||||
@Param('userName') username: string,
|
@Param('userName') username: string,
|
||||||
@Body() canEdit: boolean,
|
@Body('canEdit') canEdit: boolean,
|
||||||
): Promise<NotePermissionsDto> {
|
): Promise<NotePermissionsDto> {
|
||||||
const permissionUser = await this.userService.getUserByUsername(username);
|
const permissionUser = await this.userService.getUserByUsername(username);
|
||||||
const returnedNote = await this.permissionService.setUserPermission(
|
const returnedNote = await this.permissionService.setUserPermission(
|
||||||
|
@ -285,7 +285,7 @@ export class NotesController {
|
||||||
async changeOwner(
|
async changeOwner(
|
||||||
@RequestUser() user: User,
|
@RequestUser() user: User,
|
||||||
@RequestNote() note: Note,
|
@RequestNote() note: Note,
|
||||||
@Body() newOwner: string,
|
@Body('newOwner') newOwner: string,
|
||||||
): Promise<NoteDto> {
|
): Promise<NoteDto> {
|
||||||
const owner = await this.userService.getUserByUsername(newOwner);
|
const owner = await this.userService.getUserByUsername(newOwner);
|
||||||
return await this.noteService.toNoteDto(
|
return await this.noteService.toNoteDto(
|
||||||
|
|
|
@ -384,7 +384,7 @@ export class NotesController {
|
||||||
async changeOwner(
|
async changeOwner(
|
||||||
@RequestUser() user: User,
|
@RequestUser() user: User,
|
||||||
@RequestNote() note: Note,
|
@RequestNote() note: Note,
|
||||||
@Body() newOwner: string,
|
@Body('newOwner') newOwner: string,
|
||||||
): Promise<NoteDto> {
|
): Promise<NoteDto> {
|
||||||
const owner = await this.userService.getUserByUsername(newOwner);
|
const owner = await this.userService.getUserByUsername(newOwner);
|
||||||
return await this.noteService.toNoteDto(
|
return await this.noteService.toNoteDto(
|
||||||
|
|
|
@ -12,16 +12,16 @@ import type { NotePermissions } from '@hedgedoc/commons'
|
||||||
* Sets the owner of a note.
|
* Sets the owner of a note.
|
||||||
*
|
*
|
||||||
* @param noteId The id of the 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}.
|
* @return The updated {@link NotePermissions}.
|
||||||
* @throws {Error} when the api request wasn't successful.
|
* @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>(
|
const response = await new PutApiRequestBuilder<NotePermissions, OwnerChangeDto>(
|
||||||
`notes/${noteId}/metadata/permissions/owner`
|
`notes/${noteId}/metadata/permissions/owner`
|
||||||
)
|
)
|
||||||
.withJsonBody({
|
.withJsonBody({
|
||||||
owner
|
newOwner
|
||||||
})
|
})
|
||||||
.sendRequest()
|
.sendRequest()
|
||||||
return response.asParsedJsonObject()
|
return response.asParsedJsonObject()
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
export interface OwnerChangeDto {
|
export interface OwnerChangeDto {
|
||||||
owner: string
|
newOwner: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PermissionSetDto {
|
export interface PermissionSetDto {
|
||||||
|
|
Loading…
Reference in a new issue