From 396050c6cf4fc64ff7e9e00ca45422764b1389bf Mon Sep 17 00:00:00 2001 From: Tamotsu Takahashi Date: Mon, 14 Nov 2022 01:34:15 +0900 Subject: [PATCH] Set the session cookie after registering Fix https://github.com/hedgedoc/react-client/issues/2524 Signed-off-by: Tamotsu Takahashi --- backend/src/api/private/auth/auth.controller.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/src/api/private/auth/auth.controller.ts b/backend/src/api/private/auth/auth.controller.ts index 3fc28ea01..501d5a8a8 100644 --- a/backend/src/api/private/auth/auth.controller.ts +++ b/backend/src/api/private/auth/auth.controller.ts @@ -54,13 +54,18 @@ export class AuthController { @UseGuards(RegistrationEnabledGuard) @Post('local') @OpenApi(201, 400, 409) - async registerUser(@Body() registerDto: RegisterDto): Promise { + async registerUser( + @Req() request: RequestWithSession, + @Body() registerDto: RegisterDto, + ): Promise { const user = await this.usersService.createUser( registerDto.username, registerDto.displayName, ); // ToDo: Figure out how to rollback user if anything with this calls goes wrong await this.identityService.createLocalIdentity(user, registerDto.password); + request.session.user = registerDto.username; + request.session.authProvider = 'local'; } @UseGuards(LoginEnabledGuard, SessionGuard)