Set the session cookie after registering

Fix https://github.com/hedgedoc/react-client/issues/2524

Signed-off-by: Tamotsu Takahashi <ttakah+github@gmail.com>
This commit is contained in:
Tamotsu Takahashi 2022-11-14 01:34:15 +09:00 committed by Philip Molares
parent 35f7274b7f
commit 396050c6cf

View file

@ -54,13 +54,18 @@ export class AuthController {
@UseGuards(RegistrationEnabledGuard)
@Post('local')
@OpenApi(201, 400, 409)
async registerUser(@Body() registerDto: RegisterDto): Promise<void> {
async registerUser(
@Req() request: RequestWithSession,
@Body() registerDto: RegisterDto,
): Promise<void> {
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)