Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么laravel Auth::尝试不起作用_Php_Laravel - Fatal编程技术网

Php 为什么laravel Auth::尝试不起作用

Php 为什么laravel Auth::尝试不起作用,php,laravel,Php,Laravel,在过去的30分钟里,我阅读了stackoverflow上的所有帖子。找不到解决办法。 这是我的代码: public function PostLogIn(Request $request) { if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) { return redirect()->route('d

在过去的30分钟里,我阅读了stackoverflow上的所有帖子。找不到解决办法。 这是我的代码:

public function PostLogIn(Request $request)
    {

      if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {

              return redirect()->route('dashboard');
          }
      $status = 'Incorrect details';
      return view('login')->with('status',$status);

    }
在您询问之前,我将用户密码保存在注册时的散列中,密码列可以接受所有60个字符。我使用的是标准用户模型,电子邮件和密码字段的默认名称。 在某个地方读到我应该将此添加到用户模型:

  public function getAuthPassword() {
    return $this->UserEmail;
}
试过也不行。From正在正确发送数据,但由于某些原因,我的身份验证仍然失败


(我在1.5小时前创建了一篇帖子,想编辑,但被意外删除,很抱歉那个回复的家伙:)

我还可以发表评论,但如果这对你没有帮助,我会删除它

  • 确保
    $request->email
    带来任何东西(电子邮件),
    dd($request->email)

  • 同样适用于
    $request->password

  • 检查
    $request->password
    是否生成与DB中的哈希相同的哈希:

    if (Hash::check($request->password, $hashInDB)) {
        // The passwords match...
    }
    
  • 最后(实际上这应该首先完成:p)检查
    $request->email
    上的电子邮件是否与您存储在DB中的电子邮件相同


  • PS:不确定模型中的
    getAuthPassword
    ,您应该尝试在没有它的情况下进行尝试

    $request->email
    $request->password
    包含哪些内容?它们是否具有您期望的功能?它们包含表单输入的数据。是的,我在$request下做了dd(),很好!尝试删除
    getAuthPassword
    函数。