Comments

acbramley created an issue. See original summary.

acbramley’s picture

Status: Active » Needs review
StatusFileSize
new10.56 KB

Here's a first cut.

Status: Needs review » Needs work

The last submitted patch, 2: 2856469-consecutive-chars-constraint-2.patch, failed testing.

acbramley’s picture

Status: Needs work » Needs review
StatusFileSize
new10.26 KB
new1.05 KB

Woops, removed the test as the option no longer exists.

fenstrat’s picture

Status: Needs review » Needs work
+++ b/password_policy_consecutive/src/Plugin/PasswordConstraint/Consecutive.php
@@ -0,0 +1,85 @@
+      $validation->setErrorMessage($this->t('Password must have fewer than @max identical characters.', ['@max' => $max]));

Needs 'consecutive' otherwise it's ambiguous. I.e. '@max consecutive identical characters'.

acbramley’s picture

Status: Needs work » Needs review
StatusFileSize
new10.27 KB
new819 bytes

Good spotting, fixed.

fenstrat’s picture

Status: Needs review » Reviewed & tested by the community

This looks good.

nerdstein’s picture

Status: Reviewed & tested by the community » Needs work

Has this been functionally tested yet? I don't often move issues to RTBC until it's been done

Code review comments:

1. class Consecutive - Can this be ConsecutiveCharacters? This would mimic the convention used on other constraints.

nerdstein’s picture

And, really awesome job with the automated tests. I would love to see you submit a patch that refactors the tests of the other constraints :)

acbramley’s picture

@nerdstein I've tested it via the Drupal UI, yes. And thanks! I was thinking of doing just that once this gets in :)

Patch incoming refactoring the class name.

acbramley’s picture

Status: Needs work » Needs review
StatusFileSize
new8.11 KB

No interdiff here as I renamed the tests too for consistency, there was also somehow a duplicate functional test file which I've now removed.

fenstrat’s picture

Status: Needs review » Reviewed & tested by the community

@nerdstein Sorry I didn't make it clear, but yes I tested this through the UI as well as reviewing the code.

@acbramley has made the changes requested in #8 so moving back to RTBC.

aohrvetpv’s picture

Status: Reviewed & tested by the community » Needs work
$form_state->setErrorByName('max_consecutive_characters', $this->t('The number of character types must be higher than 1 otherwise all passwords will fail.'));

Shouldn't "character types" instead be "consecutive identical characters"?

Also, I am wondering if it should be mentioned somewhere this is case insensitive. I personally was not sure whether "s" and "S" would be considered "identical". Is the case insensitivity non-obvious to anyone else or just me?

acbramley’s picture

Status: Needs work » Needs review
StatusFileSize
new8.12 KB
new2.35 KB

Fixed #13.

fenstrat’s picture

Status: Needs review » Needs work

Fix for #13 looks good.

@AohRveTPV this is case sensitive, so "ss" will trigger a password fail (if max_consecutive_characters == 2) while "sS" will not.
I'd say adding a ", case sensitive." note onto the message "Password must have fewer than 2 consecutive identical characters." should help clear that up. Marking as Needs work for that.

acbramley’s picture

Status: Needs work » Needs review
StatusFileSize
new8.14 KB
new905 bytes

Fixes #15

fenstrat’s picture

Status: Needs review » Reviewed & tested by the community

Great, thanks!

aohrvetpv’s picture

Status: Reviewed & tested by the community » Needs work

I ran Coder on the patched code and it gave a warning:

FILE: ...password_policy_consecutive/password_policy_consecutive.info.yml                   
|  ----------------------------------------------------------------------                      
|  FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE                                               
|  ----------------------------------------------------------------------                      
|   7 | WARNING | All dependencies must be prefixed with the project                           
|     |         | name, for example "drupal:"                                                  
|  ---------------------------------------------------------------------- 

I'll plan to make the fix later, but an updated patch is welcome. Haven't yet reviewed/tested the patch.

acbramley’s picture

Status: Needs work » Needs review
StatusFileSize
new8.16 KB
new449 bytes
fenstrat’s picture

Status: Needs review » Reviewed & tested by the community

Well spotted @AohRveTPV, thanks @acbramley.

  • nerdstein committed 38a5e4b on 8.x-3.x authored by acbramley
    Issue #2856469 by acbramley: Implement consecutive characters constraint
    
nerdstein’s picture

Status: Reviewed & tested by the community » Fixed

This looks good, thank you.

Status: Fixed » Closed (fixed)

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

aohrvetpv’s picture

I implemented this constraint for 7.x-1.x. A website I work on needed it. Do not plan to add it to 7.x-1.x, just wanted to share it here.

aohrvetpv’s picture

Inadvertently uploaded a case-insensitive version of this constraint in #24.

Here is a 7.x-1.x implementation of the constraint that should behave the same as the 7.x-2.x and 8.x-3.x implementations.