Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add support for all request types when building a user from request. #747

Merged
merged 10 commits into from
May 23, 2023

Conversation

sammyskills
Copy link
Contributor

Previously, the ValidationRules::buildUserFromRequest() only checks for POSTed requests.

With this PR, it can now check for any type of request including json requests.

Fixes #612

@datamweb datamweb added the enhancement New feature or request label May 18, 2023
@datamweb datamweb requested a review from kenjis May 18, 2023 19:47
Copy link
Collaborator

@datamweb datamweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
See what Kenjis says.

@kenjis
Copy link
Member

kenjis commented May 19, 2023

Can you tell me why you need this? A use case?

@sammyskills
Copy link
Contributor Author

Can you tell me why you need this? A use case?

Yes.

A use case is trying to register users using JWT authentication.
If the developer expects the request to be sent as a JSON request, and the strong password rulestrong_password is added to the validation rules, it will return an error.

@kenjis
Copy link
Member

kenjis commented May 19, 2023

@sammyskills Thanks. I think strong_password[] works.

@sammyskills sammyskills requested a review from kenjis May 20, 2023 11:47
kenjis
kenjis previously approved these changes May 23, 2023
@kenjis kenjis dismissed their stale review May 23, 2023 10:22

There is a PHPStan error.

@kenjis
Copy link
Member

kenjis commented May 23, 2023

We cannot remove the method call, so suppress the PHPStan error at that point.

 ------ -------------------------------------------------------------- 
  Line   src/Authentication/Passwords/ValidationRules.php              
 ------ -------------------------------------------------------------- 
  42     Call to deprecated method buildUserFromRequest() of class     
         CodeIgniter\Shield\Authentication\Passwords\ValidationRules:  
         This will be removed soon.                                    
 ------ -------------------------------------------------------------- 

https://github.com/codeigniter4/shield/actions/runs/5031981449/jobs/9025363859?pr=747

@sammyskills
Copy link
Contributor Author

Fixed.

@sammyskills sammyskills requested a review from kenjis May 23, 2023 13:49
@kenjis kenjis merged commit 7c07326 into codeigniter4:develop May 23, 2023
@kenjis
Copy link
Member

kenjis commented May 23, 2023

@sammyskills Thank you!

@sammyskills sammyskills deleted the support-all-requests branch May 24, 2023 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: ValidationRules::buildUserFromRequest() does not support json input
4 participants