refactor: convert config variables to upper case

This commit is contained in:
Elias Schneider
2022-12-05 16:53:52 +01:00
parent d4a0f1a4f1
commit 0499548dd3
20 changed files with 54 additions and 51 deletions

View File

@@ -28,7 +28,7 @@ export class AuthController {
@Throttle(10, 5 * 60)
@Post("signUp")
async signUp(@Body() dto: AuthRegisterDTO) {
if (!this.config.get("allowRegistration"))
if (!this.config.get("ALLOW_REGISTRATION"))
throw new ForbiddenException("Registration is not allowed");
return this.authService.signUp(dto);
}

View File

@@ -30,7 +30,7 @@ export class AuthService {
email: dto.email,
username: dto.username,
password: hash,
isAdmin: !this.config.get("setupFinished"),
isAdmin: !this.config.get("SETUP_FINISHED"),
},
});
@@ -74,7 +74,7 @@ export class AuthService {
throw new ForbiddenException("Invalid password");
const hash = await argon.hash(newPassword);
this.prisma.user.update({
where: { id: user.id },
data: { password: hash },
@@ -89,7 +89,7 @@ export class AuthService {
},
{
expiresIn: "15min",
secret: this.config.get("jwtSecret"),
secret: this.config.get("JWT_SECRET"),
}
);
}

View File

@@ -11,7 +11,7 @@ export class JwtGuard extends AuthGuard("jwt") {
try {
return (await super.canActivate(context)) as boolean;
} catch {
return this.config.get("allowUnauthenticatedShares");
return this.config.get("ALLOW_UNAUTHENTICATED_SHARES");
}
}
}

View File

@@ -8,10 +8,10 @@ import { PrismaService } from "src/prisma/prisma.service";
@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
constructor(config: ConfigService, private prisma: PrismaService) {
config.get("jwtSecret");
config.get("JWT_SECRET");
super({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
secretOrKey: config.get("jwtSecret"),
secretOrKey: config.get("JWT_SECRET"),
});
}