mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-22 09:46:30 -05:00
feat: setupSpecialGroups in bootstrap
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
bcf35c61a5
commit
0470497ccb
2 changed files with 37 additions and 0 deletions
|
@ -14,6 +14,7 @@ import { AuthConfig } from './config/auth.config';
|
|||
import { MediaConfig } from './config/media.config';
|
||||
import { ConsoleLoggerService } from './logger/console-logger.service';
|
||||
import { BackendType } from './media/backends/backend-type.enum';
|
||||
import { setupSpecialGroups } from './utils/createSpecialGroups';
|
||||
import { setupFrontendProxy } from './utils/frontend-integration';
|
||||
import { setupSessionMiddleware } from './utils/session';
|
||||
import { setupValidationPipe } from './utils/setup-pipes';
|
||||
|
@ -51,6 +52,8 @@ async function bootstrap(): Promise<void> {
|
|||
setupFrontendProxy(app, logger);
|
||||
}
|
||||
|
||||
await setupSpecialGroups(app);
|
||||
|
||||
setupSessionMiddleware(app, authConfig);
|
||||
|
||||
app.enableCors({
|
||||
|
|
34
src/utils/createSpecialGroups.ts
Normal file
34
src/utils/createSpecialGroups.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||
|
||||
import { AlreadyInDBError } from '../errors/errors';
|
||||
import { GroupsService } from '../groups/groups.service';
|
||||
import { SpecialGroup } from '../groups/groups.special';
|
||||
|
||||
export async function setupSpecialGroups(
|
||||
app: NestExpressApplication,
|
||||
): Promise<void> {
|
||||
const groupService = app.get<GroupsService>(GroupsService);
|
||||
try {
|
||||
await groupService.createGroup(
|
||||
SpecialGroup.EVERYONE,
|
||||
SpecialGroup.EVERYONE,
|
||||
true,
|
||||
);
|
||||
await groupService.createGroup(
|
||||
SpecialGroup.LOGGED_IN,
|
||||
SpecialGroup.LOGGED_IN,
|
||||
true,
|
||||
);
|
||||
} catch (e) {
|
||||
if (e instanceof AlreadyInDBError) {
|
||||
// It's no problem if the special groups already exist
|
||||
return;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue