config verify password working

This commit is contained in:
Ozzieisaacs 2022-06-16 10:44:42 +02:00
parent 73d48e4ac1
commit d6a31e5db8
4 changed files with 40 additions and 32 deletions

View File

@ -24,8 +24,12 @@ $(document).ready(function() {
}, },
}, function () { }, function () {
if ($('#password').data("verify")) {
// Initialized and ready to go // Initialized and ready to go
var options = {}; var options = {};
options.common = {
minChar: $('#password').data("min")
}
options.ui = { options.ui = {
bootstrap3: true, bootstrap3: true,
showProgressBar: false, showProgressBar: false,
@ -35,18 +39,18 @@ $(document).ready(function() {
options.rules= { options.rules= {
activated: { activated: {
wordNotEmail: false, wordNotEmail: false,
wordMinLength: true, wordMinLength: $('#password').data("min") ? true : false,
// wordMaxLength: false, // wordMaxLength: false,
// wordInvalidChar: true, // wordInvalidChar: true,
wordSimilarToUsername: false, wordSimilarToUsername: false,
wordSequences: false, wordSequences: false,
wordTwoCharacterClasses: false, wordTwoCharacterClasses: false,
wordRepetitions: false, wordRepetitions: false,
//wordLowercase: true, wordLowercase: $('#password').data("lower") ? true : false,
//wordUppercase: true, wordUppercase: $('#password').data("upper") ? true : false,
wordOneNumber: true, wordOneNumber: $('#password').data("number") ? true : false,
wordThreeNumbers: false, wordThreeNumbers: false,
wordOneSpecialChar: true, wordOneSpecialChar: $('#password').data("special") ? true : false,
// wordTwoSpecialChar: true, // wordTwoSpecialChar: true,
wordUpperLowerCombo: false, wordUpperLowerCombo: false,
wordLetterNumberCombo: false, wordLetterNumberCombo: false,
@ -54,5 +58,6 @@ $(document).ready(function() {
} }
} }
$('#password').pwstrength(options); $('#password').pwstrength(options);
}
}); });
}); });

View File

@ -352,6 +352,7 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
</div>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h4 class="panel-title"> <h4 class="panel-title">
@ -370,9 +371,8 @@
<option value="1" {% if config.config_session == 1 %}selected{% endif %}>{{_('Strong')}}</option> <option value="1" {% if config.config_session == 1 %}selected{% endif %}>{{_('Strong')}}</option>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="checkbox" id="config_password_policy" data-control="password_settings" name="config_password_policy" {% if config.config_password %}checked{% endif %}> <input type="checkbox" id="config_password_policy" data-control="password_settings" name="config_password_policy" {% if config.config_password_policy %}checked{% endif %}>
<label for="config_password_policy">{{_('User Password policy')}}</label> <label for="config_password_policy">{{_('User Password policy')}}</label>
</div> </div>
<div data-related="password_settings"> <div data-related="password_settings">
@ -393,13 +393,14 @@
<label for="config_password_upper">{{_('Enforce uppercase characters')}}</label> <label for="config_password_upper">{{_('Enforce uppercase characters')}}</label>
</div> </div>
<div class="form-group" style="margin-left:10px;"> <div class="form-group" style="margin-left:10px;">
<input type="checkbox" id="config_password_special" name="config_password_special" {% if config.config_kobo_proxy %}checked{% endif %}> <input type="checkbox" id="config_password_special" name="config_password_special" {% if config.config_password_special %}checked{% endif %}>
<label for="config_password_special">{{_('Enforce special characters')}}</label> <label for="config_password_special">{{_('Enforce special characters')}}</label>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>
<div class="col-sm-12"> <div class="col-sm-12">
<button type="button" name="submit" id="config_submit" class="btn btn-default">{{_('Save')}}</button> <button type="button" name="submit" id="config_submit" class="btn btn-default">{{_('Save')}}</button>

View File

@ -21,7 +21,7 @@
{% endif %} {% endif %}
<div class="form-group"> <div class="form-group">
<label for="password">{{_('Password')}}</label> <label for="password">{{_('Password')}}</label>
<input type="password" class="form-control" name="password" id="password" data-lang="{{ g.user.locale }}" value="" autocomplete="off"> <input type="password" class="form-control" name="password" id="password" data-lang="{{ g.user.locale }}" data-verify="{{ config.config_password_policy }}" {% if config.config_password_policy %} data-min={{ config.config_password_min_length }} data-special={{ config.config_password_special }} data-upper={{ config.config_password_upper }} data-lower={{ config.config_password_lower }} data-number={{ config.config_password_number }}{% endif %} value="" autocomplete="off">
</div> </div>
{% endif %} {% endif %}
<div class="form-group"> <div class="form-group">

View File

@ -1382,6 +1382,7 @@ def change_profile(kobo_support, local_oauth_check, oauth_status, translations,
flash(str(ex), category="error") flash(str(ex), category="error")
return render_title_template("user_edit.html", return render_title_template("user_edit.html",
content=current_user, content=current_user,
config=config,
translations=translations, translations=translations,
profile=1, profile=1,
languages=languages, languages=languages,
@ -1433,6 +1434,7 @@ def profile():
profile=1, profile=1,
languages=languages, languages=languages,
content=current_user, content=current_user,
config=config,
kobo_support=kobo_support, kobo_support=kobo_support,
title=_(u"%(name)s's profile", name=current_user.name), title=_(u"%(name)s's profile", name=current_user.name),
page="me", page="me",