diff --git a/src/routes/auth/login.ts b/src/routes/auth/login.ts
index a0fc1190..218a56ae 100644
--- a/src/routes/auth/login.ts
+++ b/src/routes/auth/login.ts
@@ -3,7 +3,7 @@ import { check, FieldErrors, Length } from "../../util/instanceOf";
import bcrypt from "bcrypt";
import jwt from "jsonwebtoken";
import { UserModel } from "@fosscord/server-util";
-import Config from "../../util/Config";
+import * as Config from "../../util/Config";
import { adjustEmail } from "./register";
const router: Router = Router();
@@ -25,7 +25,9 @@ router.post(
const query: any[] = [{ phone: login }];
if (email) query.push({ email });
- const config = Config.get();
+ // TODO: Rewrite this to have the proper config syntax on the new method
+
+ const config = Config.apiConfig.store as unknown as Config.DefaultOptions;
if (config.login.requireCaptcha && config.security.captcha.enabled) {
if (!captcha_key) {
@@ -67,9 +69,10 @@ export async function generateToken(id: string) {
const algorithm = "HS256";
return new Promise((res, rej) => {
+ const securityPropertiesSecret = Config.apiConfig.get('security.jwtSecret') as Config.DefaultOptions;
jwt.sign(
{ id: id, iat },
- Config.get().security.jwtSecret,
+ securityPropertiesSecret.security.jwtSecret,
{
algorithm,
},
diff --git a/src/routes/auth/register.ts b/src/routes/auth/register.ts
index 265516d7..6389fb22 100644
--- a/src/routes/auth/register.ts
+++ b/src/routes/auth/register.ts
@@ -1,5 +1,5 @@
import { Request, Response, Router } from "express";
-import Config from "../../util/Config";
+import * as Config from "../../util/Config";
import { trimSpecial, User, Snowflake, UserModel } from "@fosscord/server-util";
import bcrypt from "bcrypt";
import { check, Email, EMAIL_REGEX, FieldErrors, Length } from "../../util/instanceOf";
@@ -52,7 +52,8 @@ router.post(
let discriminator = "";
// get register Config
- const { register, security } = Config.get();
+ const securityProperties = Config.apiConfig.store as unknown as Config.DefaultOptions;
+ const { register, security } = securityProperties;
// check if registration is allowed
if (!register.allowNewRegistration) {
@@ -90,13 +91,13 @@ router.post(
},
});
}
- } else if (register.email.required) {
+ } else if (register.email.necessary) {
throw FieldErrors({
email: { code: "BASE_TYPE_REQUIRED", message: req.t("common:field.BASE_TYPE_REQUIRED") },
});
}
- if (register.dateOfBirth.required && !date_of_birth) {
+ if (register.dateOfBirth.necessary && !date_of_birth) {
throw FieldErrors({
date_of_birth: { code: "BASE_TYPE_REQUIRED", message: req.t("common:field.BASE_TYPE_REQUIRED") },
});
|