feat: add new config strategy to backend

This commit is contained in:
Elias Schneider
2022-11-28 15:04:32 +01:00
parent 13f98cc32c
commit 1b5e53ff7e
19 changed files with 304 additions and 50 deletions

View File

@@ -5,8 +5,8 @@ import {
HttpCode,
Post,
} from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { Throttle } from "@nestjs/throttler";
import { ConfigService } from "src/config/config.service";
import { AuthService } from "./auth.service";
import { AuthRegisterDTO } from "./dto/authRegister.dto";
import { AuthSignInDTO } from "./dto/authSignIn.dto";
@@ -21,8 +21,8 @@ export class AuthController {
@Throttle(10, 5 * 60)
@Post("signUp")
signUp(@Body() dto: AuthRegisterDTO) {
if (this.config.get("ALLOW_REGISTRATION") == "false")
async signUp(@Body() dto: AuthRegisterDTO) {
if (!this.config.get("allowRegistration"))
throw new ForbiddenException("Registration is not allowed");
return this.authService.signUp(dto);
}