Skip to content

Commit f6aee4f

Browse files
authored
Merge pull request #998 from rubensworks/feature/disable-password-checks
Add disable-password-checks option, Closes #983
2 parents b6f8e48 + f4dad83 commit f6aee4f

File tree

6 files changed

+30
-10
lines changed

6 files changed

+30
-10
lines changed

bin/lib/options.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,14 @@ module.exports = [
351351
validate: validUri,
352352
when: answers => answers['enforce-toc']
353353
},
354+
{
355+
name: 'disable-password-checks',
356+
help: 'Do you want to disable password strength checking?',
357+
flag: true,
358+
prompt: true,
359+
default: false,
360+
when: answers => answers.multiuser
361+
},
354362
{
355363
name: 'support-email',
356364
help: 'The support email you provide for your users (not required)',

common/js/solid.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
PasswordValidator.prototype.fetchDomNodes = function () {
4646
this.form = this.passwordField.closest('form')
4747

48+
this.disablePasswordChecks = this.passwordField.classList.contains('disable-password-checks')
49+
4850
this.passwordGroup = this.passwordField.closest('.form-group')
4951
this.passwordFeedback = this.passwordGroup.querySelector('.form-control-feedback')
5052
this.passwordStrengthMeter = this.passwordGroup.querySelector('.progress-bar')
@@ -69,8 +71,10 @@
6971
this.errors = []
7072
this.resetValidation(this.passwordGroup)
7173
this.resetFeedbackIcon(this.passwordFeedback)
72-
this.displayPasswordErrors()
73-
this.instantFeedbackForPassword()
74+
if (!this.disablePasswordChecks) {
75+
this.displayPasswordErrors()
76+
this.instantFeedbackForPassword()
77+
}
7478
}
7579

7680
/**
@@ -99,14 +103,17 @@
99103
PasswordValidator.prototype.validatePassword = function () {
100104
this.errors = []
101105
const password = this.passwordField.value
102-
const passwordStrength = this.getPasswordStrength(password)
103-
this.currentStrengthLevel = this.getStrengthLevel(passwordStrength)
104106

105-
if (passwordStrength.errors) {
106-
this.addPasswordError(passwordStrength.errors)
107-
}
107+
if (!this.disablePasswordChecks) {
108+
const passwordStrength = this.getPasswordStrength(password)
109+
this.currentStrengthLevel = this.getStrengthLevel(passwordStrength)
110+
111+
if (passwordStrength.errors) {
112+
this.addPasswordError(passwordStrength.errors)
113+
}
108114

109-
this.checkLeakedPassword(password).then(this.handleLeakedPasswordResponse.bind(this))
115+
this.checkLeakedPassword(password).then(this.handleLeakedPasswordResponse.bind(this))
116+
}
110117

111118
this.setPasswordFeedback()
112119
}

config.json-default

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"logo": ""
1717
},
1818
"enforceToc": true,
19+
"disablePasswordChecks": false,
1920
"tocUri": "https://your-toc",
2021
"supportEmail": "Your support email address"
2122
}

default-views/account/register-form.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
<div class="form-group has-feedback">
3838
<label class="control-label" for="password">Password*</label>
39-
<input type="password" class="form-control control-progress" name="password" id="password" required/>
39+
<input type="password" class="form-control control-progress{{#if disablePasswordStrengthCheck}} disable-password-strength-check{{/if}}" name="password" id="password" required/>
4040
<span class="glyphicon glyphicon-remove form-control-feedback hidden" aria-hidden="true"></span>
4141
<div class="progress">
4242
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="4"></div>

lib/create-app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ function initAppLocals (app, argv, ldp) {
137137
app.locals.tokenService = new TokenService()
138138
app.locals.enforceToc = argv.enforceToc
139139
app.locals.tocUri = argv.tocUri
140+
app.locals.disablePasswordChecks = argv.disablePasswordChecks
140141

141142
if (argv.email && argv.email.host) {
142143
app.locals.emailService = new EmailService(argv.templates.email, argv.email)

lib/requests/create-account-request.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class CreateAccountRequest extends AuthRequest {
3838
this.username = options.username
3939
this.userAccount = options.userAccount
4040
this.acceptToc = options.acceptToc
41+
this.disablePasswordChecks = options.disablePasswordChecks
4142
}
4243

4344
/**
@@ -69,6 +70,7 @@ class CreateAccountRequest extends AuthRequest {
6970

7071
options.enforceToc = locals.enforceToc
7172
options.tocUri = locals.tocUri
73+
options.disablePasswordChecks = locals.disablePasswordChecks
7274

7375
switch (authMethod) {
7476
case 'oidc':
@@ -113,7 +115,8 @@ class CreateAccountRequest extends AuthRequest {
113115
multiuser: this.accountManager.multiuser,
114116
registerDisabled: authMethod === 'tls',
115117
returnToUrl: this.returnToUrl,
116-
tocUri: this.tocUri
118+
tocUri: this.tocUri,
119+
disablePasswordChecks: this.disablePasswordChecks
117120
})
118121

119122
if (error) {

0 commit comments

Comments
 (0)