summary refs log tree commit diff
path: root/src/routes/auth
diff options
context:
space:
mode:
authorDiego Magdaleno <diegomagdaleno@protonmail.com>2021-05-21 18:18:58 -0500
committerDiego Magdaleno <diegomagdaleno@protonmail.com>2021-05-21 18:18:58 -0500
commit05057b922a84c6b0331357867dfa50166320b318 (patch)
tree55b1ccb6e0ce0347a3f9e93932fa4acd81b5bf24 /src/routes/auth
parentMeta: Clean up the format file (diff)
downloadserver-05057b922a84c6b0331357867dfa50166320b318.tar.xz
Config: Refactor config method, so we have a new get all option, fix issues in configurations
Diffstat (limited to 'src/routes/auth')
-rw-r--r--src/routes/auth/login.ts5
-rw-r--r--src/routes/auth/register.ts3
2 files changed, 3 insertions, 5 deletions
diff --git a/src/routes/auth/login.ts b/src/routes/auth/login.ts

index 218a56ae..1938b794 100644 --- a/src/routes/auth/login.ts +++ b/src/routes/auth/login.ts
@@ -27,7 +27,7 @@ router.post( // TODO: Rewrite this to have the proper config syntax on the new method - const config = Config.apiConfig.store as unknown as Config.DefaultOptions; + const config = Config.apiConfig.getAll(); if (config.login.requireCaptcha && config.security.captcha.enabled) { if (!captcha_key) { @@ -69,10 +69,9 @@ 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 }, - securityPropertiesSecret.security.jwtSecret, + Config.apiConfig.getAll().security.jwtSecret, { algorithm, }, diff --git a/src/routes/auth/register.ts b/src/routes/auth/register.ts
index 6389fb22..ca6351fa 100644 --- a/src/routes/auth/register.ts +++ b/src/routes/auth/register.ts
@@ -52,8 +52,7 @@ router.post( let discriminator = ""; // get register Config - const securityProperties = Config.apiConfig.store as unknown as Config.DefaultOptions; - const { register, security } = securityProperties; + const { register, security } = Config.apiConfig.getAll(); // check if registration is allowed if (!register.allowNewRegistration) {