Changeset 130
- Timestamp:
- 07/20/07 15:00:20 (1 year ago)
- Files:
-
- branch/views/users/admin_edit.ctp (modified) (1 diff)
- branch/webroot/js/jquery.passstrength.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branch/views/users/admin_edit.ctp
r118 r130 7 7 <?php e($form->input('username', array('class' => 'required')));?> 8 8 <?php e($form->input('passwd', array('class' => 'required')));?> 9 <div style="width: 100px;"> 10 <div id="UserPasswd_text" style="font-size: 10px;"></div> 11 <div id="UserPasswd_bar" style="border: 1px solid white; font-size: 1px; height: 2px; width: 0px;"/></div> 12 </div> 9 13 <?php e($form->input('name', array('class' => 'required')));?> 10 14 <?php e($form->input('email'));?> branch/webroot/js/jquery.passstrength.js
r128 r130 10 10 (function($) { 11 11 12 function checkPassword( strPassword, settings)12 function checkPassword(passwd, settings) 13 13 { 14 // Reset combination count 15 nCombinations = 0; 16 // Check numbers 17 if (settings.bCheckNumbers) 14 var intScore = 0; 15 var strVerdict = settings.verdects[0]; 16 17 // PASSWORD LENGTH 18 if (passwd.length<5) // length 4 or less 18 19 { 19 strCheck = "0123456789"; 20 if (doesContain(strPassword, strCheck) > 0) 21 { 22 nCombinations += strCheck.length; 23 } 20 intScore = (intScore + 3) 24 21 } 25 // Check upper case 26 if (settings.bCheckUpperCase) 22 else if (passwd.length>4 && passwd.length<8) // length between 5 and 7 27 23 { 28 strCheck = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 29 if (doesContain(strPassword, strCheck) > 0) 30 { 31 nCombinations += strCheck.length; 32 } 24 intScore = (intScore+6) 33 25 } 34 // Check lower case 35 if (settings.bCheckLowerCase) 26 else if (passwd.length>7 && passwd.length<16)// length between 8 and 15 36 27 { 37 strCheck = "abcdefghijklmnopqrstuvwxyz"; 38 if (doesContain(strPassword, strCheck) > 0) 39 { 40 nCombinations += strCheck.length; 41 } 28 intScore = (intScore+12) 42 29 } 43 // Check punctuation 44 if (settings.bCheckPunctuation) 30 else if (passwd.length>15) // length 16 or more 45 31 { 46 strCheck = ";:-_=+\|//?^&!.@$£#*()%~<>{}[]"; 47 if (doesContain(strPassword, strCheck) > 0) 48 { 49 nCombinations += strCheck.length; 50 } 32 intScore = (intScore+18) 51 33 } 52 // Calculate 53 // -- 500 tries per second => minutes 54 var nDays = ((Math.pow(nCombinations, strPassword.length) / 500) / 2) / 86400; 55 56 // Number of days out of password lifetime setting 57 var nPerc = nDays / settings.nPasswordLifetime; 58 59 return nPerc; 34 // LETTERS (Not exactly implemented as dictacted above because of my limited understanding of Regex) 35 if (passwd.match(/[a-z]/)) // [verified] at least one lower case letter 36 { 37 intScore = (intScore+1) 38 } 39 if (passwd.match(/[A-Z]/)) // [verified] at least one upper case letter 40 { 41 intScore = (intScore+5) 42 } 43 // NUMBERS 44 if (passwd.match(/\d+/)) // [verified] at least one number 45 { 46 intScore = (intScore+5) 47 } 48 if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/)) // [verified] at least three numbers 49 { 50 intScore = (intScore+5) 51 } 52 // SPECIAL CHAR 53 if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)) // [verified] at least one special character 54 { 55 intScore = (intScore+5) 56 } 57 // [verified] at least two special characters 58 if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) 59 { 60 intScore = (intScore+5) 61 } 62 // COMBOS 63 if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) // [verified] both upper and lower case 64 { 65 intScore = (intScore+2) 66 } 67 if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/)) // [verified] both letters and numbers 68 { 69 intScore = (intScore+2) 70 } 71 // [verified] letters, numbers, and special characters 72 if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)) 73 { 74 intScore = (intScore+2) 75 } 76 console.log(intScore); 77 return intScore; 60 78 } 61 79 … … 80 98 ctlBar.style.width = nRound + "%"; 81 99 // Color and text 82 if (nRound > 95) 83 { 84 strText = "Very Secure"; 85 strColor = "#3bce08"; 86 } 87 else if (nRound > 75) 88 { 89 strText = "Secure"; 90 strColor = "orange"; 100 101 102 if(nPerc < 16) 103 { 104 strColor = "red"; 105 strText = settings.verdects[0]; 91 106 } 92 else if (nRound > 50) 93 { 94 strText = "Mediocre"; 95 strColor = "#ffd801"; 96 } 97 else 98 { 99 strColor = "red"; 100 strText = "Insecure"; 101 } 107 else if (nPerc > 15 && nPerc < 25) 108 { 109 strColor = "#ffd801"; 110 strText = settings.verdects[1]; 111 } 112 else if (nPerc > 24 && nPerc < 35) 113 { 114 strColor = "#ffd801"; 115 strText = settings.verdects[2]; 116 } 117 else if (nPerc > 34 && nPerc < 45) 118 { 119 strColor = "orange"; 120 strText = settings.verdects[3]; 121 } 122 else 123 { 124 strColor = "#3bce08"; 125 strText = settings.verdects[4]; 126 } 102 127 ctlBar.style.backgroundColor = strColor; 103 128 ctlText.innerHTML = "<span style='color: " + strColor + ";'>" + strText + "</span>"; … … 127 152 /* Default Settings*/ 128 153 settings = jQuery.extend({ 129 bCheckNumbers: true, 130 bCheckUpperCase: true, 131 bCheckLowerCase: true, 132 bCheckPunctuation: true, 133 nPasswordLifetime: 365 154 verdects: ['very weak', 'weak', 'medium', 'strong', 'stronger'] 134 155 },settings); 135 156