Replace check password strength in toolshed change_password

This commit is contained in:
Alireza Heidari
2022-01-23 17:50:35 +03:30
parent 716c462665
commit ca47d97cb5
@@ -1,14 +1,4 @@
<%inherit file="/base.mako"/>
<script>
$(function() {
$("[name='password']").complexify({'minimumChars':6}, function(valid, complexity){
var progressBar = $('.progress-bar');
var color = valid ? 'lightgreen' : 'red';
progressBar.css('background-color', color);
progressBar.css({'width': complexity + '%'});
});
});
</script>
<div class="toolForm">
<form name="change_password" id="change_password" action="${h.url_for( controller='user', action='change_password' )}" method="post" >
@@ -40,3 +30,25 @@ $(function() {
</div>
</form>
</div>
<script>
var pwInput = document.getElementById('password_input');
pwInput.onkeyup = function() {
var pw = pwInput.value;
var progress_bar = document.getElementById('password_strength');
var strongPasswordRegex = new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})");
var mediumPasswordRegex = new RegExp("^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})");
if (strongPasswordRegex.test(pw)) {
progress_bar.style.backgroundColor = 'lightgreen';
progress_bar.style.width = '100%';
} else if (mediumPasswordRegex.test(pw)) {
progress_bar.style.backgroundColor = 'orange';
progress_bar.style.width = '60%';
} else {
progress_bar.style.backgroundColor = 'red';
progress_bar.style.width = '30%';
}
};
</script>