Skip to content

Commit

Permalink
cleaned up defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Motlagh committed Oct 4, 2023
1 parent d873a05 commit 96cfeab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/api/accounts/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 1 addition & 9 deletions src/api/authGroup/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
8 changes: 4 additions & 4 deletions src/api/authGroup/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 6 additions & 4 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
};

Expand Down

0 comments on commit 96cfeab

Please sign in to comment.