Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 1 | // Example starter JavaScript for disabling form submissions if there are invalid fields |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 2 | (function() { |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 3 | 'use strict'; |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 4 | window.addEventListener('load', function() { |
Marc Kupietz | 4fc9eeb | 2023-03-21 17:56:34 +0100 | [diff] [blame] | 5 | const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]') |
| 6 | const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)) |
Marc Kupietz | 145f5b9 | 2023-03-09 20:39:31 +0100 | [diff] [blame] | 7 | update_total_due(); |
Marc Kupietz | 8252b6d | 2023-03-10 06:46:32 +0100 | [diff] [blame] | 8 | update_paper_id_field(); |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 9 | // Fetch all the forms we want to apply custom Bootstrap validation styles to |
| 10 | var forms = document.getElementsByClassName('needs-validation'); |
| 11 | // Loop over them and prevent submission |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 12 | var validation = Array.prototype.filter.call(forms, function(form) { |
| 13 | form.addEventListener('submit', function(event) { |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 14 | if (form.checkValidity() === false) { |
| 15 | event.preventDefault(); |
| 16 | event.stopPropagation(); |
| 17 | } |
Marc Kupietz | 8b80c7a | 2023-03-28 21:41:39 +0200 | [diff] [blame] | 18 | update_total_due(); |
Marc Kupietz | 6eb2c9f | 2023-03-30 17:13:52 +0200 | [diff] [blame] | 19 | update_paper_id_field(); |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 20 | form.classList.add('was-validated'); |
| 21 | }, false); |
| 22 | }); |
| 23 | }, false); |
Marc Kupietz | 8b80c7a | 2023-03-28 21:41:39 +0200 | [diff] [blame] | 24 | window.addEventListener('popstate', function(event) { |
| 25 | update_total_due(); |
Marc Kupietz | 6eb2c9f | 2023-03-30 17:13:52 +0200 | [diff] [blame] | 26 | update_paper_id_field(); |
Marc Kupietz | 8b80c7a | 2023-03-28 21:41:39 +0200 | [diff] [blame] | 27 | }, false); |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 28 | })(); |
| 29 | |
Marc Kupietz | 145f5b9 | 2023-03-09 20:39:31 +0100 | [diff] [blame] | 30 | function update_total_due() { |
Marc Kupietz | 0be2b46 | 2023-03-08 09:29:11 +0100 | [diff] [blame] | 31 | var costs = 0; |
Marc Kupietz | 0dbe6b6 | 2023-03-21 17:58:11 +0100 | [diff] [blame] | 32 | var vegetarian_dinner = $("#vegetarian_dinner"); |
Marc Kupietz | 0be2b46 | 2023-03-08 09:29:11 +0100 | [diff] [blame] | 33 | |
Marc Kupietz | 0dbe6b6 | 2023-03-21 17:58:11 +0100 | [diff] [blame] | 34 | if ($('#conference_dinner').is(":checked")) { |
| 35 | vegetarian_dinner.removeAttr('disabled'); |
| 36 | } else { |
| 37 | vegetarian_dinner.attr('disabled', 'disabled'); |
| 38 | } |
Marc Kupietz | 0be2b46 | 2023-03-08 09:29:11 +0100 | [diff] [blame] | 39 | |
| 40 | if ($('#participate').is(":checked")) { |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 41 | costs += parseInt($("#conference_fee").text(), 10); |
Marc Kupietz | 0be2b46 | 2023-03-08 09:29:11 +0100 | [diff] [blame] | 42 | if ($('#student').is(":checked")) { |
| 43 | costs -= parseInt($("#student_discount").text(), 10); |
| 44 | } |
| 45 | if ($('#conference_dinner').is(":checked")) { |
| 46 | costs += parseInt($("#conference_dinner_price").text(), 10); |
| 47 | } |
Marc Kupietz | 8b80c7a | 2023-03-28 21:41:39 +0200 | [diff] [blame] | 48 | if ($('#excursion').is(":checked")) { |
| 49 | costs += parseInt($("#excursion_price").text(), 10); |
| 50 | } |
Marc Kupietz | 79eaa0b | 2023-03-16 17:33:43 +0100 | [diff] [blame] | 51 | const lunches = ["lunch_day_1", "lunch_day_2", "lunch_day_3"]; |
| 52 | lunches.forEach(function(lunch) { |
| 53 | if ($("input[name='" + lunch + "']:checked").val() != "--") { |
| 54 | costs += parseInt($("#lunch_costs").text().replace(/[^0-9]/g, ''), 10) / 100; |
| 55 | } |
| 56 | }); |
Marc Kupietz | 0be2b46 | 2023-03-08 09:29:11 +0100 | [diff] [blame] | 57 | } |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 58 | $("#total_due").val(costs.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })); |
Marc Kupietz | 0be2b46 | 2023-03-08 09:29:11 +0100 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | function update_paper_id_field() { |
| 62 | var paper_id = $("#paper_id"); |
| 63 | if ($('#author').is(":checked")) { |
| 64 | paper_id.removeAttr('disabled'); |
Marc Kupietz | 6eb2c9f | 2023-03-30 17:13:52 +0200 | [diff] [blame] | 65 | paper_id.attr('pattern', '[1-9]\\d{0,3}'); |
Marc Kupietz | 0be2b46 | 2023-03-08 09:29:11 +0100 | [diff] [blame] | 66 | paper_id.attr('required', 'required'); |
Marc Kupietz | ce13e96 | 2023-03-21 17:54:33 +0100 | [diff] [blame] | 67 | val = paper_id.val(); |
Marc Kupietz | 6eb2c9f | 2023-03-30 17:13:52 +0200 | [diff] [blame] | 68 | if (!val.match(/^\d{1,4}$/)) { |
Marc Kupietz | ce13e96 | 2023-03-21 17:54:33 +0100 | [diff] [blame] | 69 | paper_id.val(''); |
| 70 | } |
Marc Kupietz | 0be2b46 | 2023-03-08 09:29:11 +0100 | [diff] [blame] | 71 | } else { |
Marc Kupietz | 0be2b46 | 2023-03-08 09:29:11 +0100 | [diff] [blame] | 72 | paper_id.attr('disabled', 'disabled'); |
Marc Kupietz | ce13e96 | 2023-03-21 17:54:33 +0100 | [diff] [blame] | 73 | paper_id.val(''); |
Marc Kupietz | 0be2b46 | 2023-03-08 09:29:11 +0100 | [diff] [blame] | 74 | paper_id.removeAttr('placeholder'); |
| 75 | paper_id.removeAttr('pattern'); |
| 76 | paper_id.removeAttr('required'); |
| 77 | } |
| 78 | } |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 79 | |
| 80 | function check_password_match() { |
| 81 | pass = $("#pw1").val(); |
| 82 | pass2 = $("#pw2").val(); |
| 83 | |
| 84 | if (pass2.length > 0) { |
| 85 | $("#pwconfirm")[0].classList.add('was-validated') |
| 86 | if (pass != pass2) { |
| 87 | $("#pw2")[0].setCustomValidity("Passwords do not match"); |
| 88 | } else { |
| 89 | $("#pw2")[0].setCustomValidity(""); // is valid |
| 90 | } |
| 91 | } else { |
| 92 | $("#pwconfirm")[0].classList.remove('was-validated') |
| 93 | } |
| 94 | passUpdated(); |
| 95 | } |
| 96 | |
| 97 | TOO_SHORT = 'Password too short, still %% characters needed'; |
| 98 | TOO_LONG = 'Password too long, please remove %% characters'; |
Marc Kupietz | b169df3 | 2023-04-20 11:54:36 +0200 | [diff] [blame] | 99 | INVALID_CHARS = 'Invalid characters: only a-z, A-Z, 0-9 and !@#$%()_+=:;",.?/- are allowed.'; |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 100 | QUAL_NONE = 'Password is very weak' |
| 101 | QUAL_LOW = 'Password is weak'; |
| 102 | QUAL_MEDIUM = 'Password is average' |
| 103 | QUAL_GOOD = 'Password is good'; |
| 104 | QUAL_STRONG = 'Password is strong'; |
| 105 | REP_OK = 'Repetition ok'; |
| 106 | REP_NE = 'Passwords not identical'; |
| 107 | PWNED = 'Password found in public password list'; |
| 108 | |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 109 | String.prototype.strReverse = function() { |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 110 | var newstring = ''; |
| 111 | for (var s = 0; s < this.length; s++) |
| 112 | newstring = this.charAt(s) + newstring; |
| 113 | return newstring; |
| 114 | }; |
| 115 | |
| 116 | function isPasswordPwned(pass, callback) { |
| 117 | const sha1Hash = CryptoJS.enc.Hex.stringify(CryptoJS.SHA1(pass)).toUpperCase(); |
| 118 | const passwordChunk1 = sha1Hash.substring(0, 5); |
| 119 | const passwordChunk2 = sha1Hash.substring(5); |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 120 | $.get('https://api.pwnedpasswords.com/range/' + passwordChunk1).done(function(data, status) { |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 121 | var isPwned = false; |
| 122 | if (status == "success") { |
| 123 | if (data && data.length) { |
| 124 | const chunks = data.split('\r\n'); |
| 125 | const matches = chunks.filter(s => s.includes(passwordChunk2)); |
| 126 | |
| 127 | if (matches.length) { |
| 128 | isPwned = true |
| 129 | } |
| 130 | } |
| 131 | callback(isPwned) |
| 132 | } |
| 133 | }); |
| 134 | } |
| 135 | |
| 136 | //var checkTimer; |
| 137 | |
| 138 | function passUpdated() { |
| 139 | var nScore = 0; |
| 140 | var message = ''; |
| 141 | |
| 142 | var pass = $('#pw1').val(); |
| 143 | var pass2 = $('#pw2').val(); |
| 144 | |
| 145 | //clearTimeout(checkTimer); |
| 146 | |
| 147 | try { |
| 148 | if (!pass) |
| 149 | throw ''; |
| 150 | |
| 151 | if (pass.match(/[^a-zA-Z0-9!@#$%()_+=:;",.?/-]/)) |
| 152 | throw INVALID_CHARS; |
| 153 | |
| 154 | var nLength = pass.length; |
| 155 | if (nLength < 8) |
| 156 | throw TOO_SHORT.replace('%%', 8 - nLength); |
Marc Kupietz | b169df3 | 2023-04-20 11:54:36 +0200 | [diff] [blame] | 157 | if (nLength > 128) |
| 158 | throw TOO_LONG.replace('%%', nLength - 128); |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 159 | |
| 160 | nScore = 4 * nLength; |
| 161 | |
| 162 | // check for upper-/lowercase, numeric and special chars pattern matches |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 163 | var nAlphaUC = 0, |
| 164 | nAlphaLC = 0, |
| 165 | nNumber = 0, |
| 166 | nSpecial = 0; |
| 167 | var nMidChar = 0, |
| 168 | nRepChar = 0, |
| 169 | nRepInc = 0; |
| 170 | var nConsecAlphaUC = 0, |
| 171 | nConsecAlphaLC = 0, |
| 172 | nConsecNumber = 0; |
| 173 | var nTmpAlphaUC = '', |
| 174 | nTmpAlphaLC = '', |
| 175 | nTmpNumber = ''; |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 176 | for (var i = 0; i < nLength; i++) { |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 177 | if (pass[i].match(/[A-Z]/g)) { // uppercase characters |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 178 | if (nTmpAlphaUC !== '' && (nTmpAlphaUC + 1) == i) { |
| 179 | nConsecAlphaUC++; |
| 180 | } |
| 181 | nTmpAlphaUC = i; |
| 182 | nAlphaUC++; |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 183 | } else if (pass[i].match(/[a-z]/g)) { // lowercase characters |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 184 | if (nTmpAlphaLC !== '' && (nTmpAlphaLC + 1) == i) { |
| 185 | nConsecAlphaLC++; |
| 186 | } |
| 187 | nTmpAlphaLC = i; |
| 188 | nAlphaLC++; |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 189 | } else if (pass[i].match(/[0-9]/g)) { // numbers |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 190 | if (i > 0 && i < (nLength - 1)) { |
| 191 | nMidChar++; |
| 192 | } |
| 193 | if (nTmpNumber !== '' && (nTmpNumber + 1) == i) { |
| 194 | nConsecNumber++; |
| 195 | } |
| 196 | nTmpNumber = i; |
| 197 | nNumber++; |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 198 | } else { // special characters |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 199 | if (i > 0 && i < (nLength - 1)) { |
| 200 | nMidChar++; |
| 201 | } |
| 202 | nSpecial++; |
| 203 | } |
| 204 | |
| 205 | // check for repeated characters |
| 206 | var bCharExists = false; |
| 207 | for (var j = 0; j < nLength; j++) { |
| 208 | if (pass[i] == pass[j] && i != j) { |
| 209 | bCharExists = true; |
| 210 | nRepInc += Math.abs(nLength / (j - i)); |
| 211 | } |
| 212 | } |
| 213 | if (bCharExists) { |
| 214 | nRepChar++; |
| 215 | var nUnqChar = nLength - nRepChar; |
| 216 | nRepInc = (nUnqChar) ? Math.ceil(nRepInc / nUnqChar) : Math.ceil(nRepInc); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | // check for sequential alpha string patterns (forward and reverse) |
| 221 | var sAlphas = "abcdefghijklmnopqrstuvwxyz"; |
| 222 | var nSeqAlpha = 0; |
| 223 | for (var i = 0; i < 23; i++) { |
| 224 | var sFwd = sAlphas.substring(i, i + 3); |
| 225 | var sRev = sFwd.strReverse(); |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 226 | if (pass.toLowerCase().indexOf(sFwd) != -1 || |
| 227 | pass.toLowerCase().indexOf(sRev) != -1) |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 228 | nSeqAlpha++; |
| 229 | } |
| 230 | |
| 231 | // check for sequential numeric string patterns (forward and reverse) |
| 232 | var sNumerics = "01234567890"; |
| 233 | var nSeqNumber = 0; |
| 234 | for (var i = 0; i < 8; i++) { |
| 235 | var sFwd = sNumerics.substring(i, i + 3); |
| 236 | var sRev = sFwd.strReverse(); |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 237 | if (pass.toLowerCase().indexOf(sFwd) != -1 || |
| 238 | pass.toLowerCase().indexOf(sRev) != -1) |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 239 | nSeqNumber++; |
| 240 | } |
| 241 | |
| 242 | // general point assignment |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 243 | if (nAlphaUC > 0 && nAlphaUC < nLength) // uppercase characters |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 244 | nScore += 2 * (nLength - nAlphaUC); |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 245 | if (nAlphaLC > 0 && nAlphaLC < nLength) // lowercase characters |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 246 | nScore += 2 * (nLength - nAlphaLC); |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 247 | if (nNumber > 0 && nNumber < nLength) // numbers |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 248 | nScore += 2 * nNumber; |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 249 | if (nSpecial > 0) // special characters |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 250 | nScore += 4 * nSpecial; |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 251 | if (nMidChar > 0) // mid numbers/special characters |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 252 | nScore += 2 * nMidChar; |
| 253 | |
| 254 | // point deductions for poor practices |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 255 | if ((nAlphaLC > 0 || nAlphaUC > 0) && |
| 256 | nSpecial === 0 && nNumber === 0) // characters only |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 257 | nScore -= nLength; |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 258 | if (nAlphaLC === 0 && nAlphaUC === 0 && |
| 259 | nSpecial === 0 && nNumber > 0) // numbers only |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 260 | nScore -= nLength; |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 261 | if (nRepChar > 0) // same character exists more than once |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 262 | nScore -= nRepInc; |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 263 | if (nConsecAlphaUC > 0) // consecutive uppercase letters exist |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 264 | nScore -= 2 * nConsecAlphaUC; |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 265 | if (nConsecAlphaLC > 0) // consecutive lowercase letters exist |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 266 | nScore -= 2 * nConsecAlphaLC; |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 267 | if (nConsecNumber > 0) // consecutive numbers exist |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 268 | nScore -= 2 * nConsecNumber; |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 269 | if (nSeqAlpha > 0) // sequential alpha strings exist (3 chars or more) |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 270 | nScore -= 3 * nSeqAlpha; |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 271 | if (nSeqNumber > 0) // sequential numeric strings exist (3 chars or more) |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 272 | nScore -= 3 * nSeqNumber; |
| 273 | |
| 274 | // determine if mandatory requirements have been met |
| 275 | var arrChars = [nAlphaUC, nAlphaLC, nNumber, nSpecial]; |
| 276 | var nReqChar = 0; |
| 277 | for (var i = 0; i < arrChars.length; i++) { |
| 278 | if (arrChars[i]) { |
| 279 | nReqChar++; |
| 280 | } |
| 281 | } |
| 282 | if (nReqChar >= arrChars.length) |
| 283 | nScore += 2 * nReqChar; |
| 284 | else if (nReqChar < arrChars.length - 1) |
| 285 | nScore -= 2 * nReqChar; |
| 286 | |
| 287 | // limit points to 3..100 |
| 288 | nScore = Math.max(3, Math.min(nScore, 100)); |
| 289 | |
| 290 | // set message according to points |
| 291 | if (nScore >= 80) |
| 292 | message = QUAL_STRONG; |
| 293 | else if (nScore >= 60) |
| 294 | message = QUAL_GOOD; |
| 295 | else if (nScore >= 40) |
| 296 | message = QUAL_MEDIUM; |
| 297 | else if (nScore >= 10) |
| 298 | message = QUAL_LOW; |
| 299 | else |
| 300 | message = QUAL_NONE; |
| 301 | } catch (error) { |
| 302 | nScore = 3; |
| 303 | message = error; |
| 304 | } |
| 305 | /* |
| 306 | if (pass.length > 0 && pass2.length > 0) { |
| 307 | message+=' / '; |
| 308 | message+=(pass == pass2) ? REP_OK : REP_NE; |
| 309 | } |
| 310 | */ |
| 311 | $('#pwqinfo').val(message); |
| 312 | |
| 313 | var progress = $('#pwqbar'); |
| 314 | progress.width(nScore + '%'); |
| 315 | progress.attr('aria-valuenow', nScore); |
| 316 | if (nScore >= 60) |
| 317 | progress.removeClass('bg-danger bg-warning').addClass('bg-success'); |
| 318 | else if (nScore >= 40) |
| 319 | progress.removeClass('bg-danger bg-success').addClass('bg-warning'); |
| 320 | else |
| 321 | progress.removeClass('bg-warning bg-success').addClass('bg-danger'); |
| 322 | |
| 323 | if (nScore >= 40) { |
| 324 | $("#password-div")[0].classList.add('was-validated'); |
| 325 | $('#btn_change').prop('disabled', pass !== pass2); |
| 326 | $("#pw1")[0].setCustomValidity(""); |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 327 | isPasswordPwned(pass, function(isPwned) { |
Marc Kupietz | 484ec8e | 2023-02-25 11:23:07 +0100 | [diff] [blame] | 328 | if (isPwned) { |
| 329 | $('#pwqinfo').val(PWNED); |
| 330 | progress.removeClass().addClass('low'); |
| 331 | progress.val(3); |
| 332 | $("#pw1")[0].setCustomValidity("Password is pwned"); |
| 333 | } |
| 334 | }); |
| 335 | } else { |
| 336 | $("#password-div")[0].classList.add('was-validated'); |
| 337 | $('#btn_change').prop('disabled', 1); |
| 338 | $("#pw1")[0].setCustomValidity("Password is to week"); |
| 339 | } |
| 340 | |
Marc Kupietz | f190316 | 2023-03-10 13:54:23 +0100 | [diff] [blame] | 341 | } |