mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-25 04:24:43 -04: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
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
import { Body, Controller, Delete, Get, Post, UseGuards } from '@nestjs/common';
|
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 { SessionGuard } from '../../../identity/session.guard';
|
||||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||||
|
@ -35,7 +35,7 @@ export class MeController {
|
||||||
getMe(
|
getMe(
|
||||||
@RequestUser() user: User,
|
@RequestUser() user: User,
|
||||||
@SessionAuthProvider() authProvider: string,
|
@SessionAuthProvider() authProvider: string,
|
||||||
): UserInfoDto {
|
): UserLoginInfoDto {
|
||||||
return this.userService.toUserLoginInfoDto(user, authProvider);
|
return this.userService.toUserLoginInfoDto(user, authProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,10 +61,19 @@ export class MeController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('profile')
|
@Post('profile')
|
||||||
|
@ApiBody({
|
||||||
|
schema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
displayName: { type: 'string', nullable: false },
|
||||||
|
},
|
||||||
|
required: ['displayName'],
|
||||||
|
},
|
||||||
|
})
|
||||||
@OpenApi(200)
|
@OpenApi(200)
|
||||||
async updateDisplayName(
|
async updateDisplayName(
|
||||||
@RequestUser() user: User,
|
@RequestUser() user: User,
|
||||||
@Body('name') newDisplayName: string,
|
@Body('displayName') newDisplayName: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await this.userService.changeDisplayName(user, newDisplayName);
|
await this.userService.changeDisplayName(user, newDisplayName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ describe('Me', () => {
|
||||||
await agent
|
await agent
|
||||||
.post('/api/private/me/profile')
|
.post('/api/private/me/profile')
|
||||||
.send({
|
.send({
|
||||||
name: newDisplayName,
|
displayName: newDisplayName,
|
||||||
})
|
})
|
||||||
.expect(201);
|
.expect(201);
|
||||||
const dbUser = await testSetup.userService.getUserByUsername('hardcoded');
|
const dbUser = await testSetup.userService.getUserByUsername('hardcoded');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue