Skip to content

Commit

Permalink
Merge pull request #747 from sammyskills/support-all-requests
Browse files Browse the repository at this point in the history
fix: add support for all request types when building a user from request.
  • Loading branch information
kenjis authored May 23, 2023
2 parents 736a88f + eedc945 commit 7c07326
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/guides/strengthen_password.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The longer the password, the stronger it is. Consider increasing the value.

> **Note**
>
> This checking works when you validate passwords with the `strong_password`
> This checking works when you validate passwords with the `strong_password[]`
> validation rule.
>
> If you disable `CompositionValidator` (enabled by default) in `$passwordValidators`,
Expand Down
5 changes: 5 additions & 0 deletions src/Authentication/Passwords/ValidationRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function strong_password(string $value, ?string &$error1 = null, array $d
if (function_exists('auth') && auth()->user()) {
$user = auth()->user();
} else {
/** @phpstan-ignore-next-line */
$user = empty($data) ? $this->buildUserFromRequest() : $this->buildUserFromData($data);
}

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

/**
* Builds a new user instance from the global request.
*
* @deprecated This will be removed soon.
*
* @see https://github.com/codeigniter4/shield/pull/747#discussion_r1198778666
*/
protected function buildUserFromRequest(): User
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ protected function getValidationRules(): array
],
'password' => [
'label' => 'Auth.password',
'rules' => 'required|' . Passwords::getMaxLengthRule() . '|strong_password',
'rules' => 'required|' . Passwords::getMaxLengthRule() . '|strong_password[]',
'errors' => [
'max_byte' => 'Auth.errorPasswordTooLongBytes',
],
Expand Down

0 comments on commit 7c07326

Please sign in to comment.