removing redundant code
This commit is contained in:
parent
242e7f956b
commit
6154bff69b
|
@ -39,7 +39,7 @@ def before_request():
|
|||
@login_required
|
||||
def profile():
|
||||
if request.method == 'GET':
|
||||
return render_template('user_profile.html',user_info = current_user.get_user_info_by_username() )
|
||||
return render_template('user_profile.html',user_info = current_user.get_user_info_by_username(), zxcvbn_enabled=Setting().get('zxcvbn_enabled') )
|
||||
if request.method == 'POST':
|
||||
if session['authentication_type'] == 'LOCAL':
|
||||
firstname = request.form.get('firstname', '').strip()
|
||||
|
@ -48,7 +48,7 @@ def profile():
|
|||
new_password = request.form.get('password', '')
|
||||
if not password_quality_check(current_user, new_password):
|
||||
# return render_template('errors/400.html', msg="Password does not meet the policy requirements")
|
||||
return render_template('user_profile.html', change_pass_tab = True, user_info = current_user.get_user_info_by_username() ,error="Password does not meet the policy requirements")
|
||||
return render_template('user_profile.html', change_pass_tab = True, user_info = current_user.get_user_info_by_username() , zxcvbn_enabled=Setting().get('zxcvbn_enabled'), error="Password does not meet the policy requirements")
|
||||
else:
|
||||
firstname = lastname = email = new_password = ''
|
||||
current_app.logger.warning(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% macro password_policy(zxcvbn_enabled) -%}
|
||||
{% macro password_policy(zxcvbn_enabled, pwd_min_len, pwd_min_digits, pwd_min_uppercase, pwd_min_lowercase, pwd_min_special, pwd_must_not_contain) -%}
|
||||
{{ caller() }}
|
||||
|
||||
{% if zxcvbn_enabled == false %}
|
||||
|
@ -14,12 +14,12 @@ $(':input').on('keyup', function() {
|
|||
else {
|
||||
document.getElementById('retype-err').innerHTML = '';
|
||||
}
|
||||
var pwd_len = parseInt("{{ SETTING.get('pwd_min_len') }}");
|
||||
var n_upper = parseInt("{{ SETTING.get('pwd_min_uppercase') }}");
|
||||
var n_lower = parseInt("{{ SETTING.get('pwd_min_lowercase') }}");
|
||||
var n_digits = parseInt("{{ SETTING.get('pwd_min_digits') }}");
|
||||
var n_special = parseInt("{{ SETTING.get('pwd_min_special') }}");
|
||||
var must_not_contain = "{{ SETTING.get('pwd_must_not_contain') }}";
|
||||
var pwd_len = parseInt("{{ pwd_min_len }}");
|
||||
var n_upper = parseInt("{{ pwd_min_uppercase }}");
|
||||
var n_lower = parseInt("{{ pwd_min_lowercase }}");
|
||||
var n_digits = parseInt("{{ pwd_min_digits }}");
|
||||
var n_special = parseInt("{{ pwd_min_special }}");
|
||||
var must_not_contain = "{{ pwd_must_not_contain }}";
|
||||
var pattern = "^(?=(?:.*[0-9]){" + n_digits + ",})(?=(?:.*[a-z]){" + n_lower + ",})(?=(?:.*[A-Z]){" + n_upper + ",})(?=(?:.*[[!@#$%^&*()_+]){" + n_special + ",}).+$";
|
||||
|
||||
var PasswordRegEx = new RegExp(pattern, 'm');
|
||||
|
|
|
@ -178,7 +178,7 @@
|
|||
});
|
||||
|
||||
|
||||
{% call password_policy_macro.password_policy(SETTING.get('zxcvbn_enabled')) %}
|
||||
{% call password_policy_macro.password_policy(zxcvbn_enabled, SETTING.get('pwd_min_len'), SETTING.get('pwd_min_digits'), SETTING.get('pwd_min_uppercase'), SETTING.get('pwd_min_lowercase'), SETTING.get('pwd_min_special'), SETTING.get('pwd_must_not_contain')) %}
|
||||
{% endcall %}
|
||||
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue