Skip to content

Commit 7c07326

Browse files
authored
Merge pull request #747 from sammyskills/support-all-requests
fix: add support for all request types when building a user from request.
2 parents 736a88f + eedc945 commit 7c07326

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

docs/guides/strengthen_password.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The longer the password, the stronger it is. Consider increasing the value.
1717

1818
> **Note**
1919
>
20-
> This checking works when you validate passwords with the `strong_password`
20+
> This checking works when you validate passwords with the `strong_password[]`
2121
> validation rule.
2222
>
2323
> If you disable `CompositionValidator` (enabled by default) in `$passwordValidators`,

src/Authentication/Passwords/ValidationRules.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function strong_password(string $value, ?string &$error1 = null, array $d
4040
if (function_exists('auth') && auth()->user()) {
4141
$user = auth()->user();
4242
} else {
43+
/** @phpstan-ignore-next-line */
4344
$user = empty($data) ? $this->buildUserFromRequest() : $this->buildUserFromData($data);
4445
}
4546

@@ -66,6 +67,10 @@ public function max_byte(?string $str, string $val): bool
6667

6768
/**
6869
* Builds a new user instance from the global request.
70+
*
71+
* @deprecated This will be removed soon.
72+
*
73+
* @see https://github.com/codeigniter4/shield/pull/747#discussion_r1198778666
6974
*/
7075
protected function buildUserFromRequest(): User
7176
{

src/Controllers/RegisterController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ protected function getValidationRules(): array
197197
],
198198
'password' => [
199199
'label' => 'Auth.password',
200-
'rules' => 'required|' . Passwords::getMaxLengthRule() . '|strong_password',
200+
'rules' => 'required|' . Passwords::getMaxLengthRule() . '|strong_password[]',
201201
'errors' => [
202202
'max_byte' => 'Auth.errorPasswordTooLongBytes',
203203
],

0 commit comments

Comments
 (0)