mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 06:34:39 -04:00
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:
parent
35f7274b7f
commit
396050c6cf
1 changed files with 6 additions and 1 deletions
|
@ -54,13 +54,18 @@ export class AuthController {
|
||||||
@UseGuards(RegistrationEnabledGuard)
|
@UseGuards(RegistrationEnabledGuard)
|
||||||
@Post('local')
|
@Post('local')
|
||||||
@OpenApi(201, 400, 409)
|
@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(
|
const user = await this.usersService.createUser(
|
||||||
registerDto.username,
|
registerDto.username,
|
||||||
registerDto.displayName,
|
registerDto.displayName,
|
||||||
);
|
);
|
||||||
// ToDo: Figure out how to rollback user if anything with this calls goes wrong
|
// ToDo: Figure out how to rollback user if anything with this calls goes wrong
|
||||||
await this.identityService.createLocalIdentity(user, registerDto.password);
|
await this.identityService.createLocalIdentity(user, registerDto.password);
|
||||||
|
request.session.user = registerDto.username;
|
||||||
|
request.session.authProvider = 'local';
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(LoginEnabledGuard, SessionGuard)
|
@UseGuards(LoginEnabledGuard, SessionGuard)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue