Problem/Motivation

The user.js in Drupal core (it is attached to the password_confirm form element) uses specific markup for constructing the password strength message, password strength bar, the password match message and the password improvement tips.

Currently, markup of these elements is not overridable by themes, therefore Claro had to override the user.js file completely

We want to be able to remove Claro's user.js replacement, and only use Drupal.theme() functions (and overridden JS settings) for theming the password confirm widget.

Proposed resolution

Introduce new Drupal.theme callbacks for these components and refactor user.js to use the new Drupal.theme callbacks. Remove Claro user.js and leverage the newly added theme functions instead.

Remaining tasks

  • Provide patch
  • Create change record

User interface changes

Nothing.

API changes

Data model changes

Release notes snippet

The user module has added JavaScript theme functions have to allow customizing password confirm widget markup. Information on using these functions can be found in user.theme.es6.js.

CommentFileSizeAuthor
#53 interdiff.txt4.59 KBeffulgentsia
#53 3067523-53.patch93.2 KBeffulgentsia
#49 3067523-49.patch93.22 KBbnjmnm
#49 interdiff_45-49.txt3.67 KBbnjmnm
#45 interdiff__41--45.txt26.51 KBbnjmnm
#45 3067523--45.patch95.66 KBbnjmnm
#41 interdiff.txt1.36 KBlauriii
#41 3067523-41.patch84.44 KBlauriii
#38 interdiff-37-38.txt2.81 KBnod_
#38 core-password-3067523-38.patch84.42 KBnod_
#37 interdiff.txt29.2 KBlauriii
#37 3067523-37.patch84.6 KBlauriii
#34 intediff.txt1.01 KBlauriii
#34 3067523-34.patch76.04 KBlauriii
#32 interdiff.txt39.25 KBlauriii
#32 3067523-32.patch76 KBlauriii
#31 interdiff.txt15.21 KBlauriii
#31 3067523-31.patch72.57 KBlauriii
#27 3067523-27-reroll.patch71.91 KBlauriii
#22 3067523-22-REROLL.patch64.61 KBbnjmnm
#16 interdiff.txt630 byteslauriii
#16 3067523-16.patch64.91 KBlauriii
#14 interdiff.txt17.62 KBlauriii
#14 3067523-14.patch64.9 KBlauriii
#13 3067523-13-REROLL.patch64.64 KBbnjmnm
#12 3067523-12-REROLL.patch65.56 KBbnjmnm
#11 user-theme_functions_for_password_confirm-3067523-11--claro-fix-only.txt27.63 KBhuzooka
#11 user-theme_functions_for_password_confirm-3067523-11--user-fix-only.txt34 KBhuzooka
#11 user-theme_functions_for_password_confirm-3067523-11--complete.patch71.62 KBhuzooka
#11 user-theme_functions_for_password_confirm-3067523-11--test-only.patch10 KBhuzooka
#10 claro-password_confirm_update-3067523-10--do-not-test.patch27.63 KBhuzooka
#9 interdiff-3067523-6-9.txt24.89 KBhuzooka
#9 user-theme_functions_for_password_confirm-3067523-9--complete.patch44 KBhuzooka
#6 interdiff-3067523-5-6.txt22.02 KBhuzooka
#6 user-theme_functions_for_password_confirm-3067523-6.patch32.02 KBhuzooka
#5 interdiff-3067523-4-5.txt12.06 KBhuzooka
#5 user-theme_functions_for_password_confirm-3067523-5.patch10 KBhuzooka
#4 user-theme_functions_for_password_confirm-3067523-4.patch8.67 KBhuzooka

Comments

huzooka created an issue. See original summary.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

huzooka’s picture

Assigned: Unassigned » huzooka
Issue tags: -JavaScript +JavaScript
huzooka’s picture

Adding a raw test for ensuring that we will ship the original markup for the password confirm widget.

I'll refactor and simplify this test asap.

huzooka’s picture

huzooka’s picture

Assigned: huzooka » Unassigned
Status: Active » Needs review
StatusFileSize
new32.02 KB
new22.02 KB

Added the first patch that ships the needed new Drupal.theme callbacks:

  1. Drupal.theme.passwordStrength()
  2. Drupal.theme.passwordSuggestions()
huzooka’s picture

Assigned: Unassigned » huzooka
Issue tags: +Needs issue summary update
huzooka’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: -Needs issue summary update

IS updated:

The most important motivation here is that we want to be able to remove Claro's user.js replacement, and only use Drupal.theme() functions (and overridden settings) for the password confirm widget.

huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
StatusFileSize
new44 KB
new24.89 KB
huzooka’s picture

This patch cleans up Claro after #9 is applied.

huzooka’s picture

Some summary:

The attached test-only patch ensures that we will have the pre-existing markup and functionality before; and even after the complete patch was applied.

The complete patch contains the test and the needed changes of the user module (mainly user.js and the user.theme.js) and Claro theme.

The user-fix-only file contains the changes made on user.module; the claro-fix-only file show the changes of Claro theme. These are for making the review easier.

bnjmnm’s picture

Version: 8.9.x-dev » 9.1.x-dev
StatusFileSize
new65.56 KB

Reroll for working from 9.1.x

bnjmnm’s picture

Status: Needs review » Needs work
StatusFileSize
new64.64 KB
  1. +++ b/core/modules/user/tests/src/FunctionalJavascript/PasswordConfirmWidgetTest.php
    @@ -0,0 +1,149 @@
    +    //
    +    // Now reload the page, and fill only the main input for first.
    +    //
    

    There are a few places in this test, where inline comments begin and/or end with empty lines. Those empty lines can be removed. I can see the appeal of using them for emphasis, but blank inline comments should only be used for separating paragraphs.

  2. +++ b/core/modules/user/tests/src/FunctionalJavascript/PasswordConfirmWidgetTest.php
    @@ -0,0 +1,149 @@
    +    // Password tips should be refreshed and get visible.
    +    $this->assertNotNull($this->assert->waitForElement('css', "$password_confirm_selector + .password-suggestions > ul > li"));
    +    $this->assertTrue($password_confirm_item->find('css', "$password_confirm_selector + .password-suggestions > ul > li")->isVisible());
    +    // Password match message must become invisible.
    +    $this->assertFalse($password_confirm_item->find('css', 'input.js-password-confirm + .js-password-confirm-message')->isVisible());
    +    // Password strength message should be updated.
    +    $this->assert->elementContains('css', "$password_confirm_widget_selector $password_parent_selector", '<div aria-live="polite" aria-atomic="true" class="password-strength__title">Password strength: <span class="password-strength__text js-password-strength__text">Weak</span></div>');
    +    // Deleting the input must not change the element above.
    +    $password_confirm_widget->fillField('Password', 'o');
    

    This one isn't in the code standards, but I had a committer state a strong preference for adding a blank line above inline comments if the previous line has the same indentation. I don't mind making those folks happy.

  3. +++ b/core/modules/user/user.es6.js
    @@ -16,103 +16,189 @@
    +          const addWidgetClasses = () => {
    +            $passwordWidget
    +              .addClass(
    +                $mainInput.val()
    +                  ? settings.password.cssClassPasswordFilled
    +                  : settings.password.cssClassPasswordEmpty,
    +              )
    +              .addClass(
    

    This and a few other function definitions need to be JSDoc'd.

  4. +++ b/core/modules/user/user.es6.js
    @@ -16,103 +16,189 @@
    +                // keep all the classes, but let's make sure.
    

    The phrasing here sounds uncertain. Could this be changed to something more definite sounding? If there *is* some uncertainty, it would be good to confirm the exact behavior before rewriting the comment.

  5. +++ b/core/modules/user/user.es6.js
    @@ -16,103 +16,189 @@
    +        .each(function processPasswordConfirm() {
    

    This can just be an anonymous () =>

  6. +++ b/core/modules/user/user.theme.es6.js
    @@ -3,13 +3,111 @@
    +   * Constucts a password confirm message element.
    

    s/Constucts/Constructs

  7. +++ b/core/modules/user/user.theme.es6.js
    @@ -3,13 +3,111 @@
    +   *   - If a string is returned, then it has to contains a <span>, but only
    

    could change "has to contains a" to "must contain a"

  8. +++ b/core/modules/user/user.theme.es6.js
    @@ -3,13 +3,111 @@
    +   *     Drupal.theme.passwordConfirmMessage = passwordSettings => {
    +   *       const confirmMessage = {};
    +   *       confirmMessage.item = $(
    +   *        `<div aria-live="polite" aria-atomic="true">` +
    +   *          `${passwordSettings.confirmTitle}` +
    +   *        `</div>`,
    +   *       ).append((confirmMessage.textWrapper = $('<span></span>')));
    +   *       return confirmMessage;
    

    Not sure it would pass prettier, but is there a way to put the population of confirmMessage.textWrapper on its own line? It would be helpful to have the creation of both required keys be explicit in the example.

  9. +++ b/core/modules/user/user.theme.es6.js
    @@ -3,13 +3,111 @@
    +   * Constucts a password strenght message.
    

    s/Constucts/Constructs
    s/strenght/strength

    Look for these typos throughout the patch, some appear in Claro's JS too.

  10. +++ b/core/modules/user/user.theme.es6.js
    @@ -3,13 +3,111 @@
    +   *   - item: The root jQuery element that contains the whole message,
    

    Maybe change "jQuery element" to "jQuery object" for consistency with the other property definitions.

  11. +++ b/core/modules/user/user.theme.es6.js
    @@ -3,13 +3,111 @@
    +   *   - bar: The jQuery object of the password strength bar that's width will
    ...
    +   */
    

    r/that's/whose

  12. +++ b/core/modules/user/user.es6.js
    @@ -16,103 +16,189 @@
    + const $passwordWidget = $mainInput.closest(
    + '.js-form-type-password-confirm',
    + );
    + const $confirmInput = $passwordWidget.find(
    + 'input.js-password-confirm',
    + );
    + const passwordConfirmMessage = Drupal.theme(
    + 'passwordConfirmMessage',
    + settings.password,
    + );
    +
    + const $confirmMessage =
    + typeof passwordConfirmMessage === 'string'
    + ? $(passwordConfirmMessage)
    + : passwordConfirmMessage.item;
    + const $confirmTextWrapper =
    + typeof passwordConfirmMessage === 'string'
    + ? $confirmMessage.find('span')
    + : passwordConfirmMessage.textWrapper;
    + const $confirmInputParent = $confirmInput
    + .parent()
    + .addClass('confirm-parent')
    + .append($confirmMessage);
    + const password = {};
    + const passwordStrengthBarClassesToRemove = [
    + settings.password.cssClassPasswordWeak || '',
    + settings.password.cssClassPasswordFair || '',
    + settings.password.cssClassPasswordGood || '',
    + settings.password.cssClassPasswordStrong || '',
    + ]
    + .join(' ')
    + .trim();
    + const confirmTextWrapperClassesToRemove = [
    + settings.password.cssClassPasswordsMatch || '',
    + settings.password.cssClassPasswordsNotMatch || '',
    + ]
    + .join(' ')
    + .trim();
    + const widgetClassesToRemove = [
    + settings.password.cssClassWidgetInitial || '',
    + settings.password.cssClassPasswordEmpty || '',
    + settings.password.cssClassPasswordFilled || '',
    + settings.password.cssClassConfirmEmpty || '',
    + settings.password.cssClassConfirmFilled || '',
    + ]
    + .join(' ')
    + .trim();

    This is a pretty large chunk of logic without any comments. The variable names are good, which is helpful, but this should get commented at least as well as what it replaced.

  13. +++ b/core/modules/user/user.theme.es6.js
    @@ -3,13 +3,111 @@
    +   *     Example:
    

    Move the indentation of "Example:" back two spaces.

  14. +++ b/core/modules/user/user.theme.es6.js
    @@ -3,13 +3,111 @@
    +   * @param {bool} outputEmtpyList
    

    s/outputEmtpyList/outputEmptyList (this happens a few times in this patch)

lauriii’s picture

Status: Needs work » Needs review
StatusFileSize
new64.9 KB
new17.62 KB

This should address #13.

Status: Needs review » Needs work

The last submitted patch, 14: 3067523-14.patch, failed testing. View results

lauriii’s picture

Status: Needs work » Needs review
StatusFileSize
new64.91 KB
new630 bytes

This should fix the failing test

bnjmnm’s picture

All of my feedback in #13 is addressed.

I'd like to see a change record before I'd RTBC as that would help me do a final round of review on a pretty large patch.

Also tagging with "Needs issue summary update" as the issue summary has this scoped to just creating the theme functions, but this patch also leverages those in Claro. The IS either needs to include the Claro changes, or they should be split to another issue.

lauriii’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update
lauriii’s picture

Issue tags: -Needs change record

Change record has been added

bnjmnm’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

All my review items have been addressed , and the change record is consistent with my understanding of what the patch is doing, so this can RTBC.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Looks like it no longer applies (already).

bnjmnm’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll
StatusFileSize
new64.61 KB

Reroll attached

lauriii’s picture

Status: Reviewed & tested by the community » Needs review
  1. +++ b/core/modules/user/user.libraries.yml
    @@ -3,6 +3,19 @@ drupal.user:
    +  drupalSettings:
    +    password:
    +      cssClassPasswordsMatch: 'ok'
    

    I'm not sure if we should use the drupalSettings for overriding CSS classes 🤔 I'm inclined to solving this in a follow-up, but on the other hand, solving this in a follow-up would be more difficult because we would have to mindful of breaking the API.

  2. +++ b/core/modules/user/user.libraries.yml
    @@ -3,6 +3,19 @@ drupal.user:
    +      cssClassWidgetInitial: false
    +      cssClassPasswordEmpty: false
    +      cssClassPasswordFilled: false
    +      cssClassConfirmEmpty: false
    +      cssClassConfirmFilled: false
    

    If we decide to go with this approach, should we convert these to empty strings? Currently this is relying on jQuery processing boolean values correctly. As far as I can see in their documentation, this behavior isn't documented so it might not be a good idea to rely on it.

nod_’s picture

Status: Needs review » Needs work
Related issues: +#2484623: Move all JS in modules to a js/ folder

Lot of comments! thanks for that :)

The passwordStrength and passwordConfirmMessage theme function are too smart. And it is not integrator-friendly.

+            password.$strengthBar = passwordStrength.bar;
+            password.$strengthTextWrapper =
+              passwordStrength.strengthTextWrapper;

I would rather add data attributes in the html tags (and get rid of the js-* classes, for some history #1090592: [meta] Use HTML5 data-drupal-* attributes instead of #ID selectors in Drupal.settings) and do


+            password.$strengthBar = $passwordStrength.find('[data-password-strength="indicator"]');
+            password.$strengthTextWrapper = $passwordStrength.find('[data-password-strength="text"]');

Theme functions should return strings, not objects.

Also there is #2293803: Replace confirm password element with a new element that allows toggling to view the typed password to keep in mind

nod_’s picture

After all these years I finally got dreditor on my main browser :p

  1. +++ b/core/modules/user/user.es6.js
    @@ -16,103 +16,209 @@
    +            settings.password,
    ...
    +            settings.password.cssClassPasswordWeak || '',
    +            settings.password.cssClassPasswordFair || '',
    +            settings.password.cssClassPasswordGood || '',
    +            settings.password.cssClassPasswordStrong || '',
    ...
    +            settings.password.cssClassPasswordsMatch || '',
    +            settings.password.cssClassPasswordsNotMatch || '',
    ...
    +            settings.password.cssClassWidgetInitial || '',
    +            settings.password.cssClassPasswordEmpty || '',
    +            settings.password.cssClassPasswordFilled || '',
    +            settings.password.cssClassConfirmEmpty || '',
    +            settings.password.cssClassConfirmFilled || '',
    ...
    +                  ? settings.password.cssClassPasswordFilled
    +                  : settings.password.cssClassPasswordEmpty,
    ...
    +                  ? settings.password.cssClassConfirmFilled
    +                  : settings.password.cssClassConfirmEmpty,
    ...
    +              ? settings.password.cssClassPasswordsMatch
    +              : settings.password.cssClassPasswordsNotMatch;
    ...
    +              ? settings.password.confirmSuccess
    +              : settings.password.confirmFailure;
    

    Better to make a variable like const settingsPassword = settings.password;

  2. +++ b/core/modules/user/user.libraries.yml
    @@ -3,6 +3,19 @@ drupal.user:
    +  drupalSettings:
    +    password:
    +      cssClassPasswordsMatch: 'ok'
    +      cssClassPasswordsNotMatch: 'error'
    +      cssClassPasswordWeak: 'is-weak'
    +      cssClassPasswordFair: 'is-fair'
    +      cssClassPasswordGood: 'is-good'
    +      cssClassPasswordStrong: 'is-strong'
    +      cssClassWidgetInitial: false
    +      cssClassPasswordEmpty: false
    +      cssClassPasswordFilled: false
    +      cssClassConfirmEmpty: false
    +      cssClassConfirmFilled: false
    

    We can add a level here: password.css.match, password.css.notMatch, etc.

    feels a bit old-school to go with that much capitalization :)
    Like lauriii a bit conflicted by putting class names in the settings, but it is a setting so... why not. It could also be put in a theme function, it'd be closer to the experience of overring CSS/JS, than for a themer to try to remember how to override libraries settings.

  3. +++ b/core/modules/user/user.module
    @@ -1106,7 +1106,9 @@ function user_form_process_password_confirm($element) {
    -  $element['#attached']['drupalSettings']['password'] = $password_settings;
    +  foreach ($password_settings as $config_key => $config_value) {
    +    $element['#attached']['drupalSettings']['password'][$config_key] = $config_value;
    +  }
    

    $element['#attached']['drupalSettings']['password'] += $password_settings;?

nod_’s picture

Thinking about it, shouldn't be in drupalsettings (it's for PHP to JS data) and shouldn't be in a theme function, have the list somewhere in the JS file and expose it through Drupal.password.css or something.

lauriii’s picture

Status: Needs work » Needs review
StatusFileSize
new71.91 KB

Started with a reroll

lauriii’s picture

Theme functions should return strings, not objects.

I had some reservations on the approach too. However, based on Drupal.theme documentation, it seemed like it would be an accepted return value for theme functions:

   * @return {string|object|HTMLElement|jQuery}
   *   Any data the theme function returns. This could be a plain HTML string,
   *   but also a complex object.

We could probably change the approach to use the data-drupal-selector if we agree that it's a preferred approach, but I just wanted to point out that the way I understand the documentation, this would be allowed. Maybe the documentation is incorrect or misleading and needs to be updated.

nod_’s picture

The docs are definitely not correct, this is wording from at least 2007. Definitely not in line with what we've been doing for a few years now.

lauriii’s picture

Issue tags: +Needs followup

Let's open an issue for discussing and changing that

lauriii’s picture

StatusFileSize
new72.57 KB
new15.21 KB

This should address #25. We will still have to address #24.

lauriii’s picture

Issue tags: +Needs change record
StatusFileSize
new76 KB
new39.25 KB

Changes in this patch:

  • Addressed #24 by making theme functions in the patch only return strings
  • Target elements with data-drupal-selector
  • Removed js- prefixed classes in the theme functions, added theme function overrides in Stable. We should write change record for this.
  • Added new test for Claro to ensure that there are not regressions caused by the theme function overrides in Claro.
  • Removed the BC layer for adding empty li element inside the password suggestions since it was already removed in Claro. We could add it back to Stable if we think it would be useful but I feel like it might not be necessary.

Remaining work:

  • Open follow-up for addressing #29
  • Write change record for the removal of the js- prefixed classes

Status: Needs review » Needs work

The last submitted patch, 32: 3067523-32.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

lauriii’s picture

Status: Needs work » Needs review
StatusFileSize
new76.04 KB
new1.01 KB

This should address the test failure

lauriii’s picture

nod_’s picture

Status: Needs review » Needs work

Quick review:

  1. +++ b/core/modules/user/user.es6.js
    @@ -3,7 +3,53 @@
    +   * @type {object}
    +   * @property {string} passwordParent - A CSS class for the parent element.
    +   * @property {string} passwordsMatch - A CSS class indicating password match.
    

    The rest of core use @prop, not @property.

  2. +++ b/core/modules/user/user.es6.js
    @@ -193,29 +336,32 @@
    +    // Assemble the final message while keeping the original message array.
    +    const messageTips = msg;
    +    msg = `${passwordSettings.hasWeaknesses}<ul><li>${msg.join(
    

    Shouldn't that use Drupal.theme('passwordSuggestions') ?

  3. +++ b/core/modules/user/user.theme.es6.js
    @@ -3,13 +3,82 @@
    +   * @return {string}
    +   *   This function returns markup for password strength message.
    +   */
    +  Drupal.theme.passwordStrength = passwordSettings => {
    +    const strengthIndicator =
    +      '<div class="password-strength__indicator" data-drupal-selector="password-strength-indicator"></div>';
    +    const strengthText =
    +      '<span class="password-strength__text" data-drupal-selector="password-strength-text"></span>';
    +    return $('<div class="password-strength"></div>')
    +      .append(
    +        `<div class="password-strength__meter" data-drupal-selector="password-strength-meter">${strengthIndicator}</div>`,
    +      )
    +      .append(
    +        `<div aria-live="polite" aria-atomic="true" class="password-strength__title">${passwordSettings.strengthTitle} ${strengthText}</div>`,
    +      );
    +  };
    

    It says returns string but it return an jQuery object.

  4. +++ b/core/themes/claro/claro.libraries.yml
    @@ -219,11 +219,8 @@ form.password-confirm:
    -    js/user.js: {}
    +    js/user.theme.js: {}
       dependencies:
    -    - core/jquery
    -    - core/drupal
    -    - core/jquery.once
         - claro/global-styling
    

    A bit too eager, this still depends on core/drupal since it uses the main Drupal object.

  5. +++ b/core/themes/claro/js/user.theme.js
    --- /dev/null
    +++ b/core/themes/stable9/js/user.theme.es6.js
    

    missing the compiled file no?

lauriii’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record
StatusFileSize
new84.6 KB
new29.2 KB

I've added another CR draft to address #32.

This should also address #36, and also adds BC layer for rest of the selectors where we switched from a js- prefixed class to data-drupal-selector.

nod_’s picture

StatusFileSize
new84.42 KB
new2.81 KB

Nice I didn't know we had that for deprecated JS :)

Understood why we kept the code I pointed out in #36.2

Still an issue with the dependencies, core/jquery is not used in the theme file anymore :) some estlint stuff as well as a typo in the claro theme file.

lauriii’s picture

+++ b/core/themes/claro/js/user.theme.es6.js
@@ -0,0 +1,81 @@
+(($, Drupal) => {
+  $.extend(Drupal.user.password.css, {

I added the jQuery dependency for this. Maybe we should use Object.assign instead?

nod_’s picture

oh right didn't saw that one. objec assign would be better yes

lauriii’s picture

StatusFileSize
new84.44 KB
new1.36 KB

Changed to using Object.assign instead

nod_’s picture

Status: Needs review » Reviewed & tested by the community

Looks good :)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Is possible to test the deprecations? There seem to be quite a few new deprecations added by the patch. Also the list of things that have been deprecated doesn't appear to tally with what's listed in the change records.

  1. +++ b/core/modules/user/user.es6.js
    @@ -16,103 +62,225 @@
    +          if ($confirmTextWrapper.length === 0) {
    +            $confirmTextWrapper = $passwordConfirmMessage.find('span').first();
    +            Drupal.deprecationError({
    +              message:
    +                'Returning <span> without data-drupal-selector="password-confirm-text" attribute is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/3152101',
    +            });
    +          }
    

    There doesn't appear to be test coverage of this deprecation.

  2. +++ b/core/modules/user/user.es6.js
    @@ -16,103 +62,225 @@
    +                'Returning <span> without data-drupal-selector="password-confirm-text" attribute is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/3152101',
    

    This doesn't seem to have any detail in the CR.

  3. +++ b/core/modules/user/user.es6.js
    @@ -123,13 +291,14 @@
        * @return {object}
        *   An object containing strength, message, indicatorText and indicatorClass.
        */
    -  Drupal.evaluatePasswordStrength = function(password, translate) {
    +  Drupal.evaluatePasswordStrength = (password, passwordSettings) => {
    
    @@ -193,37 +362,46 @@
    +    return Drupal.deprecatedProperty({
    +      target: {
    +        strength,
    +        message: msg,
    +        indicatorText,
    +        indicatorClass,
    +        messageTips,
    +      },
    +      deprecatedProperty: 'message',
    +      message:
    +        'The message property is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. The markup should be constructed using messageTips property and Drupal.theme.passwordSuggestions. See https://www.drupal.org/node/3130352',
    +    });
    
    

    The return now contains messageTips and message is deprecated. This deprecation is not mentioned in the CR's as far as I can see.

  4. +++ b/core/modules/user/user.js
    @@ -5,67 +5,139 @@
    -        var $confirmResult = $passwordInputParentWrapper.find('div.js-password-confirm-message');
    ...
    +        var $confirmInput = $passwordWidget.find('input.js-password-confirm');
    +        var $passwordConfirmMessage = $(Drupal.theme('passwordConfirmMessage', settings.password));
    +        var $confirmTextWrapper = $passwordConfirmMessage.find('[data-drupal-selector="password-confirm-text"]').first();
    

    The CR mentions password-confirm-message but not password-confirm-test - having both is confusing - what's the difference?

bnjmnm’s picture

Assigned: Unassigned » bnjmnm

Working on #43

bnjmnm’s picture

Assigned: bnjmnm » Unassigned
Status: Needs work » Needs review
StatusFileSize
new95.66 KB
new26.51 KB

#43.1

There doesn't appear to be test coverage of this deprecation.

Added a test that covers all deprecations introduced in this patch.

#43.2 CR rewritten to make this clearer.

#43.3 Created a new CR for this as it did not fit into the others https://www.drupal.org/node/3160593

#43.4 Once pointed out, I agree this is confusing. Did some rewriting of the CR and password-confirm-message/password-confirm-text and some associated variables are renamed to make their purpose clearer.

lauriii’s picture

Status: Needs review » Reviewed & tested by the community

+1 on adding test coverage for the deprecations. Reviewed the interdiff between #45 and #41 The test coverage looks sufficient for me. I also think that the password-match-status-text is clearer than password-confirm-text so +1 for that change 👍

effulgentsia’s picture

I've started to review this, and haven't finished yet, but so far, I'm confused about these 2 small things:

+++ b/core/modules/user/user.es6.js
@@ -16,103 +62,225 @@
+              Drupal.theme('passwordSuggestions', settings.password, [], false),

What's the false argument for?

--- a/core/themes/claro/css/components/form--password-confirm.pcss.css
+++ b/core/themes/claro/css/components/form--password-confirm.pcss.css

How are these CSS changes related to the scope of this issue?

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/user/tests/themes/password_theme_function_test/js/password-theme-functions.es6.js
    @@ -0,0 +1,91 @@
    +  Drupal.theme.passwordSuggestions = ({ hasWeaknesses }, tips) =>
    
    +++ b/core/modules/user/user.js
    

    Should we add the tips to the same object?

  2. +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
    @@ -140,6 +140,7 @@ public static function isDeprecationSkipped($message) {
    +      'hello',
    
    +++ b/core/themes/claro/claro.libraries.yml
    @@ -1,3 +1,4 @@
    +
    

    Are these changes actually needed?

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new3.67 KB
new93.22 KB

#47.1

What's the false argument for?

, looks like it's for an arg that was present in an earlier iteration of the function. It's no longer used so I removed it from the patch.

#47.2

How are these CSS changes related to the scope of this issue?

I had assumed they were added to maintain behavior that would otherwise be regressed by this patch, but after comparing to HEAD this does appear to be out of scope. I added #3167508: [PP-1] Add transition to password confirm reveal as a followup to add these transitions within an appropriate scope.

#48.1 Regarding adding tips to the same object in ({ hasWeaknesses }, tips) =>, the { hasWeaknesses } is a string that is destructured from the full passwordSettings object, while tips is a value that varies depending on what the aspiring password needs. It seems more appropriate to me to keep the passwordSettings and dynamic values separate, but open to hearing why it may be more beneficial to combine them in a single object.

#48.2 items are reviewed.

lauriii’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for explaining #48.1 and sorry for the rushed review. I somehow thought it was an options object and I thought we could have used it for passing the tips too.

Confirmed that #49 addresses #47 and #48 so moving back to RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 49: 3067523-49.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

lauriii’s picture

Status: Needs work » Reviewed & tested by the community
effulgentsia’s picture

StatusFileSize
new93.2 KB
new4.59 KB

#49 looks great. This just fixes some coding standards violations.

effulgentsia’s picture

Removing credit from myself (#53 interdiff is too trivial), and adding credit to @alexpott for #43.

  • effulgentsia committed a5665ea on 9.1.x
    Issue #3067523 by lauriii, huzooka, bnjmnm, nod_, alexpott: Add Drupal...
effulgentsia’s picture

Status: Reviewed & tested by the community » Fixed

Pushed to 9.1.x. Great work on this!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.