mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-02-23 11:11:38 +00:00
fix(api/private/me): require and document displayName
This renames the argument in the POST /profile route to `displayName` to be more consistent with the UserDTO. It also adds OpenAPI docs. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
d6ea4d29fe
commit
6944094b9b
2 changed files with 13 additions and 4 deletions
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { Body, Controller, Delete, Get, Post, UseGuards } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { ApiBody, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import { SessionGuard } from '../../../identity/session.guard';
|
||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||
|
@ -35,7 +35,7 @@ export class MeController {
|
|||
getMe(
|
||||
@RequestUser() user: User,
|
||||
@SessionAuthProvider() authProvider: string,
|
||||
): UserInfoDto {
|
||||
): UserLoginInfoDto {
|
||||
return this.userService.toUserLoginInfoDto(user, authProvider);
|
||||
}
|
||||
|
||||
|
@ -61,10 +61,19 @@ export class MeController {
|
|||
}
|
||||
|
||||
@Post('profile')
|
||||
@ApiBody({
|
||||
schema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
displayName: { type: 'string', nullable: false },
|
||||
},
|
||||
required: ['displayName'],
|
||||
},
|
||||
})
|
||||
@OpenApi(200)
|
||||
async updateDisplayName(
|
||||
@RequestUser() user: User,
|
||||
@Body('name') newDisplayName: string,
|
||||
@Body('displayName') newDisplayName: string,
|
||||
): Promise<void> {
|
||||
await this.userService.changeDisplayName(user, newDisplayName);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ describe('Me', () => {
|
|||
await agent
|
||||
.post('/api/private/me/profile')
|
||||
.send({
|
||||
name: newDisplayName,
|
||||
displayName: newDisplayName,
|
||||
})
|
||||
.expect(201);
|
||||
const dbUser = await testSetup.userService.getUserByUsername('hardcoded');
|
||||
|
|
Loading…
Reference in a new issue