From 96cfeab1d090401c133db01daaae3351bf1b0dca Mon Sep 17 00:00:00 2001 From: Bo Motlagh Date: Wed, 4 Oct 2023 16:01:30 -0400 Subject: [PATCH] cleaned up defaults --- src/api/accounts/account.js | 3 +-- src/api/authGroup/api.js | 10 +--------- src/api/authGroup/model.js | 8 ++++---- src/config.js | 10 ++++++---- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/api/accounts/account.js b/src/api/accounts/account.js index 26f7cec..88d9559 100644 --- a/src/api/accounts/account.js +++ b/src/api/accounts/account.js @@ -62,12 +62,11 @@ export default { if(p.pattern.custom) { try { policy = new RegExp(p.pattern.custom); - console.info('this worked'); custom = true; } catch(e) { const message = `Custom Password Policy did not compile - ${p.pattern.custom}. Defaulted to standard.`; if(ag) ueEvents.emit(ag, 'ue.account.error', message); - else console.error(); + else console.error(message); } } if(!policy) { diff --git a/src/api/authGroup/api.js b/src/api/authGroup/api.js index b12b5c1..80a62c8 100644 --- a/src/api/authGroup/api.js +++ b/src/api/authGroup/api.js @@ -30,15 +30,7 @@ const api = { if(req.body.setupCode !== config.ONE_TIME_PERSONAL_ROOT_CREATION_KEY) return next(Boom.unauthorized()); if(!config.ROOT_EMAIL) return next(Boom.badData('Root Email Not Configured')); if(!req.body.password) return next(Boom.badData('Need to provide a password for initial account')); - const policy = { - enabled: config.PASSWORD_POLICY.enabled, - pattern: { - characters: config.PASSWORD_POLICY.characters, - special: config.PASSWORD_POLICY.special, - number: config.PASSWORD_POLICY.number, - caps: config.PASSWORD_POLICY.caps - } - }; + const policy = config.PASSWORD_POLICY; //default policy await acct.passwordPolicy(undefined, policy, req.body.password); const check = await group.getOneByEither('root'); if(check) return next(Boom.forbidden('root is established, this action is forbidden')); diff --git a/src/api/authGroup/model.js b/src/api/authGroup/model.js index 6b5ee06..5fcf412 100644 --- a/src/api/authGroup/model.js +++ b/src/api/authGroup/model.js @@ -207,19 +207,19 @@ const authGroup = new mongoose.Schema({ pattern: { characters: { type: Number, - default: config.PASSWORD_POLICY.characters + default: config.PASSWORD_POLICY.pattern.characters }, special: { type: Boolean, - default: config.PASSWORD_POLICY.special + default: config.PASSWORD_POLICY.pattern.special }, number: { type: Boolean, - default: config.PASSWORD_POLICY.number + default: config.PASSWORD_POLICY.pattern.number }, caps: { type: Boolean, - default: config.PASSWORD_POLICY.caps + default: config.PASSWORD_POLICY.pattern.caps }, custom: String } diff --git a/src/config.js b/src/config.js index 46101b7..45a9517 100644 --- a/src/config.js +++ b/src/config.js @@ -157,10 +157,12 @@ const config = { }, PASSWORD_POLICY: { enabled: true, - characters: 6, - special: true, - number: true, - caps: true + pattern: { + characters: 10, + special: true, + number: true, + caps: true + } } };