Issue #3079738 by lauriii, saschaeggi, webchick, xjm, andrewmacpherson, shimpy, effulgentsia, Wim Leers, DyanneNova, svettes, rainbreaw, fhaeberle, ckrina, AaronMcHale, justafish, catch, charlieweb82, AntoineH, lot007, pzajacz, kostyashupenko, jasonbarrie, antonellasevero, finnsky, worldlinemine, bnjmnm, RobLoach, Dennis Cohn, huzooka, Archita Arora, joachim, jrockowitz, benjifisher, shaal, Gábor Hojtsy, quiron, L2G2, ccasals, hampercm, if-jds, abhisekmazumdar, Kami Amiga, pivica, zrpnr, BrightBold, imalabya, jhedstrom, Neslee Canil Pinto, maliknaik, junaidmasoodi, Maithri Shetty, pranav73, mandclu, modulist, nod_, philosurfer, phenaproxima, mherchel, mlncn, rafuel92, leymannx, kiboman, Swapnil_Kotwal, anevins, evankay, rfmarcelino, thamas, brianperry, idebr, joelpittet, boulaffasae, alexpott, volkerk, DuneBL, Eli-T, Mahenkvyas22: Add Claro administration theme to core
2019-10-13 20:42:58 +00:00
|
|
|
/**
|
|
|
|
* DO NOT EDIT THIS FILE.
|
|
|
|
* See the following change record for more information,
|
|
|
|
* https://www.drupal.org/node/2815083
|
|
|
|
* @preserve
|
|
|
|
**/
|
|
|
|
|
|
|
|
(function ($, Drupal) {
|
|
|
|
Drupal.behaviors.password = {
|
|
|
|
attach: function attach(context, settings) {
|
|
|
|
var $passwordInput = $(context).find('input.js-password-field').once('password');
|
|
|
|
|
|
|
|
if ($passwordInput.length) {
|
|
|
|
var translate = settings.password;
|
|
|
|
var $passwordInputParent = $passwordInput.parent();
|
|
|
|
var $passwordWidget = $passwordInput.closest('.js-form-type-password-confirm');
|
|
|
|
var $passwordConfirmInput = $passwordWidget.find('input.js-password-confirm');
|
|
|
|
var $passwordInputHelp = $(Drupal.theme.passwordInputHelp(translate.strengthTitle));
|
|
|
|
var $passwordConfirmHelp = $(Drupal.theme.passwordConfirmHelp(translate.confirmTitle));
|
|
|
|
var $passwordInputStrengthBar = $passwordInputHelp.find('.js-password-strength-bar');
|
|
|
|
var $passwordInputStrengthMessageWrapper = $passwordInputHelp.find('.js-password-strength-text');
|
|
|
|
var $passwordConfirmMatch = $passwordConfirmHelp.find('.js-password-match-text');
|
|
|
|
var $passwordSuggestionsTips = $(Drupal.theme.passwordSuggestionsTips('', '')).hide();
|
|
|
|
|
|
|
|
if (settings.password.showStrengthIndicator) {
|
|
|
|
$passwordConfirmInput.after($passwordConfirmHelp).parent().after($passwordSuggestionsTips);
|
|
|
|
$passwordInputParent.append($passwordInputHelp);
|
|
|
|
}
|
|
|
|
|
|
|
|
var passwordCheckMatch = function passwordCheckMatch(confirmInputVal) {
|
|
|
|
if (confirmInputVal) {
|
|
|
|
var success = $passwordInput.val() === confirmInputVal;
|
|
|
|
var confirmClass = success ? 'ok' : 'error';
|
|
|
|
var confirmMatchMessage = success ? translate.confirmSuccess : translate.confirmFailure;
|
|
|
|
|
|
|
|
if (!$passwordConfirmMatch.hasClass(confirmClass) || !$passwordConfirmMatch.html() === confirmMatchMessage) {
|
|
|
|
$passwordConfirmMatch.html(confirmMatchMessage).removeClass('ok error').addClass(confirmClass);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var passwordCheck = function passwordCheck() {
|
|
|
|
if (settings.password.showStrengthIndicator) {
|
|
|
|
var result = Drupal.evaluatePasswordStrength($passwordInput.val(), settings.password);
|
|
|
|
var $newSuggestions = $(Drupal.theme.passwordSuggestionsTips(translate.hasWeaknesses, result.tips));
|
|
|
|
|
|
|
|
if ($newSuggestions.html() !== $passwordSuggestionsTips.html()) {
|
|
|
|
$passwordSuggestionsTips.replaceWith($newSuggestions);
|
|
|
|
$passwordSuggestionsTips = $newSuggestions;
|
|
|
|
$passwordSuggestionsTips.toggle(result.strength !== 100);
|
|
|
|
}
|
|
|
|
|
2020-01-30 09:08:38 +00:00
|
|
|
$passwordInputStrengthBar.css('width', "".concat(result.strength, "%")).removeClass('is-weak is-fair is-good is-strong').addClass(result.indicatorClass);
|
Issue #3079738 by lauriii, saschaeggi, webchick, xjm, andrewmacpherson, shimpy, effulgentsia, Wim Leers, DyanneNova, svettes, rainbreaw, fhaeberle, ckrina, AaronMcHale, justafish, catch, charlieweb82, AntoineH, lot007, pzajacz, kostyashupenko, jasonbarrie, antonellasevero, finnsky, worldlinemine, bnjmnm, RobLoach, Dennis Cohn, huzooka, Archita Arora, joachim, jrockowitz, benjifisher, shaal, Gábor Hojtsy, quiron, L2G2, ccasals, hampercm, if-jds, abhisekmazumdar, Kami Amiga, pivica, zrpnr, BrightBold, imalabya, jhedstrom, Neslee Canil Pinto, maliknaik, junaidmasoodi, Maithri Shetty, pranav73, mandclu, modulist, nod_, philosurfer, phenaproxima, mherchel, mlncn, rafuel92, leymannx, kiboman, Swapnil_Kotwal, anevins, evankay, rfmarcelino, thamas, brianperry, idebr, joelpittet, boulaffasae, alexpott, volkerk, DuneBL, Eli-T, Mahenkvyas22: Add Claro administration theme to core
2019-10-13 20:42:58 +00:00
|
|
|
|
|
|
|
if (!$passwordInputStrengthMessageWrapper.hasClass(result.indicatorClass) || !$passwordInputStrengthMessageWrapper.html() === result.indicatorText) {
|
|
|
|
$passwordInputStrengthMessageWrapper.html(result.indicatorText).removeClass('is-weak is-fair is-good is-strong').addClass(result.indicatorClass);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$passwordWidget.removeClass('is-initial').removeClass('is-password-empty is-password-filled').removeClass('is-confirm-empty is-confirm-filled');
|
|
|
|
$passwordWidget.addClass($passwordInput.val() ? 'is-password-filled' : 'is-password-empty');
|
|
|
|
passwordCheckMatch($passwordConfirmInput.val());
|
|
|
|
$passwordWidget.addClass($passwordConfirmInput.val() ? 'is-confirm-filled' : 'is-confirm-empty');
|
|
|
|
};
|
|
|
|
|
|
|
|
$passwordWidget.addClass($passwordInput.val() ? 'is-password-filled' : 'is-password-empty').addClass($passwordConfirmInput.val() ? 'is-confirm-filled' : 'is-confirm-empty');
|
|
|
|
$passwordInput.on('input', passwordCheck);
|
|
|
|
$passwordConfirmInput.on('input', passwordCheck);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Drupal.evaluatePasswordStrength = function (password, translate) {
|
|
|
|
password = password.trim();
|
2020-01-30 09:08:38 +00:00
|
|
|
var indicatorText;
|
|
|
|
var indicatorClass;
|
Issue #3079738 by lauriii, saschaeggi, webchick, xjm, andrewmacpherson, shimpy, effulgentsia, Wim Leers, DyanneNova, svettes, rainbreaw, fhaeberle, ckrina, AaronMcHale, justafish, catch, charlieweb82, AntoineH, lot007, pzajacz, kostyashupenko, jasonbarrie, antonellasevero, finnsky, worldlinemine, bnjmnm, RobLoach, Dennis Cohn, huzooka, Archita Arora, joachim, jrockowitz, benjifisher, shaal, Gábor Hojtsy, quiron, L2G2, ccasals, hampercm, if-jds, abhisekmazumdar, Kami Amiga, pivica, zrpnr, BrightBold, imalabya, jhedstrom, Neslee Canil Pinto, maliknaik, junaidmasoodi, Maithri Shetty, pranav73, mandclu, modulist, nod_, philosurfer, phenaproxima, mherchel, mlncn, rafuel92, leymannx, kiboman, Swapnil_Kotwal, anevins, evankay, rfmarcelino, thamas, brianperry, idebr, joelpittet, boulaffasae, alexpott, volkerk, DuneBL, Eli-T, Mahenkvyas22: Add Claro administration theme to core
2019-10-13 20:42:58 +00:00
|
|
|
var weaknesses = 0;
|
|
|
|
var strength = 100;
|
|
|
|
var tips = [];
|
|
|
|
var hasLowercase = /[a-z]/.test(password);
|
|
|
|
var hasUppercase = /[A-Z]/.test(password);
|
|
|
|
var hasNumbers = /[0-9]/.test(password);
|
|
|
|
var hasPunctuation = /[^a-zA-Z0-9]/.test(password);
|
|
|
|
var $usernameBox = $('input.username');
|
|
|
|
var username = $usernameBox.length > 0 ? $usernameBox.val() : translate.username;
|
|
|
|
|
|
|
|
if (password.length < 12) {
|
|
|
|
tips.push(translate.tooShort);
|
|
|
|
strength -= (12 - password.length) * 5 + 30;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasLowercase) {
|
|
|
|
tips.push(translate.addLowerCase);
|
|
|
|
weaknesses += 1;
|
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
Issue #3079738 by lauriii, saschaeggi, webchick, xjm, andrewmacpherson, shimpy, effulgentsia, Wim Leers, DyanneNova, svettes, rainbreaw, fhaeberle, ckrina, AaronMcHale, justafish, catch, charlieweb82, AntoineH, lot007, pzajacz, kostyashupenko, jasonbarrie, antonellasevero, finnsky, worldlinemine, bnjmnm, RobLoach, Dennis Cohn, huzooka, Archita Arora, joachim, jrockowitz, benjifisher, shaal, Gábor Hojtsy, quiron, L2G2, ccasals, hampercm, if-jds, abhisekmazumdar, Kami Amiga, pivica, zrpnr, BrightBold, imalabya, jhedstrom, Neslee Canil Pinto, maliknaik, junaidmasoodi, Maithri Shetty, pranav73, mandclu, modulist, nod_, philosurfer, phenaproxima, mherchel, mlncn, rafuel92, leymannx, kiboman, Swapnil_Kotwal, anevins, evankay, rfmarcelino, thamas, brianperry, idebr, joelpittet, boulaffasae, alexpott, volkerk, DuneBL, Eli-T, Mahenkvyas22: Add Claro administration theme to core
2019-10-13 20:42:58 +00:00
|
|
|
if (!hasUppercase) {
|
|
|
|
tips.push(translate.addUpperCase);
|
|
|
|
weaknesses += 1;
|
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
Issue #3079738 by lauriii, saschaeggi, webchick, xjm, andrewmacpherson, shimpy, effulgentsia, Wim Leers, DyanneNova, svettes, rainbreaw, fhaeberle, ckrina, AaronMcHale, justafish, catch, charlieweb82, AntoineH, lot007, pzajacz, kostyashupenko, jasonbarrie, antonellasevero, finnsky, worldlinemine, bnjmnm, RobLoach, Dennis Cohn, huzooka, Archita Arora, joachim, jrockowitz, benjifisher, shaal, Gábor Hojtsy, quiron, L2G2, ccasals, hampercm, if-jds, abhisekmazumdar, Kami Amiga, pivica, zrpnr, BrightBold, imalabya, jhedstrom, Neslee Canil Pinto, maliknaik, junaidmasoodi, Maithri Shetty, pranav73, mandclu, modulist, nod_, philosurfer, phenaproxima, mherchel, mlncn, rafuel92, leymannx, kiboman, Swapnil_Kotwal, anevins, evankay, rfmarcelino, thamas, brianperry, idebr, joelpittet, boulaffasae, alexpott, volkerk, DuneBL, Eli-T, Mahenkvyas22: Add Claro administration theme to core
2019-10-13 20:42:58 +00:00
|
|
|
if (!hasNumbers) {
|
|
|
|
tips.push(translate.addNumbers);
|
|
|
|
weaknesses += 1;
|
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
Issue #3079738 by lauriii, saschaeggi, webchick, xjm, andrewmacpherson, shimpy, effulgentsia, Wim Leers, DyanneNova, svettes, rainbreaw, fhaeberle, ckrina, AaronMcHale, justafish, catch, charlieweb82, AntoineH, lot007, pzajacz, kostyashupenko, jasonbarrie, antonellasevero, finnsky, worldlinemine, bnjmnm, RobLoach, Dennis Cohn, huzooka, Archita Arora, joachim, jrockowitz, benjifisher, shaal, Gábor Hojtsy, quiron, L2G2, ccasals, hampercm, if-jds, abhisekmazumdar, Kami Amiga, pivica, zrpnr, BrightBold, imalabya, jhedstrom, Neslee Canil Pinto, maliknaik, junaidmasoodi, Maithri Shetty, pranav73, mandclu, modulist, nod_, philosurfer, phenaproxima, mherchel, mlncn, rafuel92, leymannx, kiboman, Swapnil_Kotwal, anevins, evankay, rfmarcelino, thamas, brianperry, idebr, joelpittet, boulaffasae, alexpott, volkerk, DuneBL, Eli-T, Mahenkvyas22: Add Claro administration theme to core
2019-10-13 20:42:58 +00:00
|
|
|
if (!hasPunctuation) {
|
|
|
|
tips.push(translate.addPunctuation);
|
|
|
|
weaknesses += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (weaknesses) {
|
|
|
|
case 1:
|
|
|
|
strength -= 12.5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
strength -= 25;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
strength -= 40;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
strength -= 40;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (password !== '' && password.toLowerCase() === username.toLowerCase()) {
|
|
|
|
tips.push(translate.sameAsUsername);
|
|
|
|
strength = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strength < 60) {
|
|
|
|
indicatorText = translate.weak;
|
|
|
|
indicatorClass = 'is-weak';
|
|
|
|
} else if (strength < 70) {
|
|
|
|
indicatorText = translate.fair;
|
|
|
|
indicatorClass = 'is-fair';
|
|
|
|
} else if (strength < 80) {
|
|
|
|
indicatorText = translate.good;
|
|
|
|
indicatorClass = 'is-good';
|
|
|
|
} else if (strength <= 100) {
|
|
|
|
indicatorText = translate.strong;
|
|
|
|
indicatorClass = 'is-strong';
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
strength: strength,
|
|
|
|
tips: tips,
|
|
|
|
indicatorText: indicatorText,
|
|
|
|
indicatorClass: indicatorClass
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
Drupal.theme.passwordInputHelp = function (message) {
|
2020-01-30 09:08:38 +00:00
|
|
|
return "<div class=\"password-strength\">\n <div class=\"password-strength__track\">\n <div class=\"password-strength__bar js-password-strength-bar\"></div>\n </div>\n <div aria-live=\"polite\" aria-atomic=\"true\" class=\"password-strength__title\">\n ".concat(message, " <span class=\"password-strength__text js-password-strength-text\"></span>\n </div>\n </div>");
|
Issue #3079738 by lauriii, saschaeggi, webchick, xjm, andrewmacpherson, shimpy, effulgentsia, Wim Leers, DyanneNova, svettes, rainbreaw, fhaeberle, ckrina, AaronMcHale, justafish, catch, charlieweb82, AntoineH, lot007, pzajacz, kostyashupenko, jasonbarrie, antonellasevero, finnsky, worldlinemine, bnjmnm, RobLoach, Dennis Cohn, huzooka, Archita Arora, joachim, jrockowitz, benjifisher, shaal, Gábor Hojtsy, quiron, L2G2, ccasals, hampercm, if-jds, abhisekmazumdar, Kami Amiga, pivica, zrpnr, BrightBold, imalabya, jhedstrom, Neslee Canil Pinto, maliknaik, junaidmasoodi, Maithri Shetty, pranav73, mandclu, modulist, nod_, philosurfer, phenaproxima, mherchel, mlncn, rafuel92, leymannx, kiboman, Swapnil_Kotwal, anevins, evankay, rfmarcelino, thamas, brianperry, idebr, joelpittet, boulaffasae, alexpott, volkerk, DuneBL, Eli-T, Mahenkvyas22: Add Claro administration theme to core
2019-10-13 20:42:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Drupal.theme.passwordConfirmHelp = function (message) {
|
2020-01-30 09:08:38 +00:00
|
|
|
return "<div aria-live=\"polite\" aria-atomic=\"true\" class=\"password-match-message\">".concat(message, " <span class=\"password-match-message__text js-password-match-text\"></span></div>");
|
Issue #3079738 by lauriii, saschaeggi, webchick, xjm, andrewmacpherson, shimpy, effulgentsia, Wim Leers, DyanneNova, svettes, rainbreaw, fhaeberle, ckrina, AaronMcHale, justafish, catch, charlieweb82, AntoineH, lot007, pzajacz, kostyashupenko, jasonbarrie, antonellasevero, finnsky, worldlinemine, bnjmnm, RobLoach, Dennis Cohn, huzooka, Archita Arora, joachim, jrockowitz, benjifisher, shaal, Gábor Hojtsy, quiron, L2G2, ccasals, hampercm, if-jds, abhisekmazumdar, Kami Amiga, pivica, zrpnr, BrightBold, imalabya, jhedstrom, Neslee Canil Pinto, maliknaik, junaidmasoodi, Maithri Shetty, pranav73, mandclu, modulist, nod_, philosurfer, phenaproxima, mherchel, mlncn, rafuel92, leymannx, kiboman, Swapnil_Kotwal, anevins, evankay, rfmarcelino, thamas, brianperry, idebr, joelpittet, boulaffasae, alexpott, volkerk, DuneBL, Eli-T, Mahenkvyas22: Add Claro administration theme to core
2019-10-13 20:42:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Drupal.theme.passwordSuggestionsTips = function (title, tips) {
|
2020-01-30 09:08:38 +00:00
|
|
|
return "<div class=\"password-suggestions\">".concat(tips.length ? "".concat(title, "<ul class=\"password-suggestions__tips\"><li class=\"password-suggestions__tip\">").concat(tips.join('</li><li class="password-suggestions__tip">'), "</li></ul>") : '', "</div>");
|
Issue #3079738 by lauriii, saschaeggi, webchick, xjm, andrewmacpherson, shimpy, effulgentsia, Wim Leers, DyanneNova, svettes, rainbreaw, fhaeberle, ckrina, AaronMcHale, justafish, catch, charlieweb82, AntoineH, lot007, pzajacz, kostyashupenko, jasonbarrie, antonellasevero, finnsky, worldlinemine, bnjmnm, RobLoach, Dennis Cohn, huzooka, Archita Arora, joachim, jrockowitz, benjifisher, shaal, Gábor Hojtsy, quiron, L2G2, ccasals, hampercm, if-jds, abhisekmazumdar, Kami Amiga, pivica, zrpnr, BrightBold, imalabya, jhedstrom, Neslee Canil Pinto, maliknaik, junaidmasoodi, Maithri Shetty, pranav73, mandclu, modulist, nod_, philosurfer, phenaproxima, mherchel, mlncn, rafuel92, leymannx, kiboman, Swapnil_Kotwal, anevins, evankay, rfmarcelino, thamas, brianperry, idebr, joelpittet, boulaffasae, alexpott, volkerk, DuneBL, Eli-T, Mahenkvyas22: Add Claro administration theme to core
2019-10-13 20:42:58 +00:00
|
|
|
};
|
|
|
|
})(jQuery, Drupal);
|