Skip to content

CI4: Fix validation in Login controller #3595

Closed

Description

@objecttothis

Validation is a little different in CI4 so it needs to be reworked in the Login Controller. Specifically set_message() needs to be converted. I think the validator object needs to be passed as a function parameter because it's not global like form_validation.

Activity

  1. changed the title [-]Fix validation in CI4 Login controller[/-] [+]CI4: Fix validation in Login controller[/+] on Nov 17, 2022
  2. objecttothis commented on Dec 1, 2022

    @objecttothis
    MemberAuthor

    @jekkos it's unclear to me why app\Controllers\Login.php and app\Libraries\MY_Validation.php have the same sets of functions. Can you help me understand the backstory here? I'm sort of stuck here on how to port this to CI4 format. It turns out that CI4 does have a an ability to call a function as a rule, similar to callbacks, but it's not clear how to pass parameters to this function.

    https://forum.codeigniter.com/showthread.php?tid=84992

    Currently on application load I get the following exception

    ArgumentCountError
    
    Too few arguments to function CodeIgniter\Validation\Validation::__construct(), 0 passed in /[REDACTED]/vendor/codeigniter4/framework/system/Validation/Validation.php on line 522 and exactly 2 expected
    

    That traces back to line 24 in the Login controller
    if(!$this->validate(['username' => 'required|login_check']))

  3. linked a pull request that will close this issueFeature: CodeIgniter 4 upgrade #3592on Dec 10, 2022
  4. added this to the 3.4.0 milestone on Dec 10, 2022
  5. objecttothis commented on Jan 27, 2023

    @objecttothis
    MemberAuthor

    As of 4.1.6 there was a slight change to validation results https://codeigniter.com/user_guide/installation/upgrade_416.html#validation-result-changes. We need to check to make sure our results are still as expected.

  6. self-assigned this
    on Feb 2, 2023
  7. objecttothis commented on Feb 2, 2023

    @objecttothis
    MemberAuthor

    Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions