Skip to content

Commit af66c7b

Browse files
committed
fix: $minimumPasswordLength is not in characters but in bytes
1 parent 0f79712 commit af66c7b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Authentication/Passwords/CompositionValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function check(string $password, ?User $user = null): Result
3232
throw AuthenticationException::forUnsetPasswordLength();
3333
}
3434

35-
$passed = strlen($password) >= $this->config->minimumPasswordLength;
35+
$passed = mb_strlen($password) >= $this->config->minimumPasswordLength;
3636

3737
if (! $passed) {
3838
return new Result([

tests/Unit/CompositionValidatorTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ public function testCheckFalse(): void
5151
);
5252
}
5353

54+
public function testCheckFalseMultibyte(): void
55+
{
56+
$password = '🍣😀';
57+
58+
$result = $this->validator->check($password);
59+
60+
$this->assertFalse($result->isOK());
61+
$this->assertSame(
62+
lang('Auth.errorPasswordLength', [$this->config->minimumPasswordLength]),
63+
$result->reason()
64+
);
65+
}
66+
5467
public function testCheckTrue(): void
5568
{
5669
$password = '1234567890';

0 commit comments

Comments
 (0)