【问题标题】:myth-auth bug when integrated with codeigniter与 codeigniter 集成时的神话身份验证错误
【发布时间】:2020-12-11 17:05:52
【问题描述】:

因此,与 codeigniter 集成时,myth-auth 似乎存在错误。

即使$email 为空,它也会尝试验证$password。因此抛出Undefined offset: 1 异常。

APPPATH\ThirdParty\myth-auth\src\Authentication\Passwords\NothingPersonalValidator.php 第 91 行

84         // Use the pieces as needles and haystacks and look every which way for matches.
85         if($valid)
86         {
87             // Take username apart for use as search needles
88             $needles = $this->strip_explode($userName);
89 
90             // extract local-part and domain parts from email as separate needles
91****             [$localPart, $domain] = \explode('@', $email);
92             // might be john.doe@example.com and we want all the needles we can get
93             $emailParts = $this->strip_explode($localPart);
94             if( ! empty($domain))
95             {
96                 $emailParts[] = $domain;
97             }
98             $needles = \array_merge($needles, $emailParts);

每当电子邮件字段为空时,总是会抛出该异常,而不是使用重定向返回

'电子邮件为空'

错误信息

【问题讨论】:

  • 不存在 Codeigniter 神话验证错误,因为神话验证不是 CI 的一部分。您的代码中可能存在错误,甚至最终在神话身份验证库中也可能存在错误。
  • @Vickel 我真的不明白你的意思
  • 在第 73 行之后,添加这一行: if(!$email) $valid = false;

标签: php codeigniter codeigniter-4


【解决方案1】:

所以,现在我正在使用 非常糟糕的 hack 并在 myth-auth\src\AuthController 第 180 行编辑系统文件...

$rules_part1 = [
        'username'      => 'required|alpha_numeric_space|min_length[3]|is_unique[users.username]',
        'email'         => 'required|valid_email|is_unique[users.email]',
    
    ];

    if (! $this->validate($rules_part1))
    {
        return redirect()->back()->withInput()->with('errors', service('validation')->getErrors());
    }

    $rules_part2 = [
        'password'      => 'required|strong_password',
        'pass_confirm'  => 'required|matches[password]',
    ];

    if (! $this->validate($rules_part2))
    {
        return redirect()->back()->withInput()->with('errors', service('validation')->getErrors());
    }

【讨论】:

    猜你喜欢
    • 2020-10-25
    • 1970-01-01
    • 2021-02-10
    • 1970-01-01
    • 1970-01-01
    • 2016-04-24
    • 2021-03-30
    • 1970-01-01
    • 2014-07-07
    相关资源
    最近更新 更多