1/** 2 * @file 3 */ 4 5(function ($, Drupal, drupalSettings) { 6 'use strict'; 7 Drupal.behaviors.externalPasswordReset = { 8 attach: function () { 9 $(once('external-password-reset', 'a.external-password-reset')).each(function() { 10 $(this).click(); 11 }); 12 } 13 }; 14 15 // Override the core method. 16 Drupal.evaluatePasswordStrength = function (password, translate) { 17 password = password.trim(); 18 var indicatorText = void 0; 19 var indicatorClass = void 0; 20 var weaknesses = 0; 21 var strength = 100; 22 var msg = []; 23 24 var hasLowercase = /[a-z]/.test(password); 25 var hasUppercase = /[A-Z]/.test(password); 26 var hasNumbers = /[0-9]/.test(password); 27 28 var $usernameBox = $('input.username'); 29 var username = $usernameBox.length > 0 ? $usernameBox.val() : translate.username; 30 31 if (password.length < 8) { 32 msg.push(drupalSettings.password_policy.tooShort); 33 strength -= (8 - password.length) * 5 + 30; 34 } 35 36 if (!hasLowercase) { 37 weaknesses++; 38 } 39 40 if (!hasUppercase) { 41 weaknesses++; 42 } 43 44 if (!hasNumbers) { 45 weaknesses++; 46 } 47 48 if (!hasLowercase || !hasUppercase || !hasNumbers) { 49 msg.push(drupalSettings.password_policy.characterTypes); 50 } 51 52 switch (weaknesses) { 53 case 1: 54 strength -= 12.5; 55 break; 56 57 case 2: 58 strength -= 25; 59 break; 60 61 case 3: 62 strength -= 40; 63 break; 64 65 case 4: 66 strength -= 40; 67 break; 68 } 69 70 if (password !== '' && password.toLowerCase() === username.toLowerCase()) { 71 msg.push(translate.sameAsUsername); 72 73 strength = 5; 74 } 75 76 if (strength < 60) { 77 indicatorText = translate.weak; 78 indicatorClass = 'is-weak'; 79 } else if (strength < 70) { 80 indicatorText = translate.fair; 81 indicatorClass = 'is-fair'; 82 } else if (strength < 80) { 83 indicatorText = translate.good; 84 indicatorClass = 'is-good'; 85 } else if (strength <= 100) { 86 indicatorText = translate.strong; 87 indicatorClass = 'is-strong'; 88 } 89 90 return { 91 strength: strength, 92 messageTips: msg, 93 indicatorText: indicatorText, 94 indicatorClass: indicatorClass 95 }; 96 97 }; 98 99})(jQuery, Drupal, drupalSettings);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.