【问题标题】:These credentials do not match our records.in Laravel 6这些凭据与我们的记录不匹配。在 Laravel 6 中
【发布时间】:2020-06-16 15:12:51
【问题描述】:

我在使用 laravel 6 时突然尝试在电子邮件字段上登录。

这些凭据与我们的记录不符。

我检查了我的数据库并输入了正确的电子邮件,我收到了这个错误

另外,我搜索了很多关于这个问题,但我没有得到任何解决方案

注意:我已经尝试过这个功能,但它也不起作用

    public function setPasswordAttribute($password)
{
    $this->attributes['password'] = \Hash::make($password);
}

登录控制器

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = RouteServiceProvider::HOME;

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }
}

【问题讨论】:

  • 可能是您的密码不正确,而不是电子邮件
  • 不,这是正确的
  • 你怎么知道的?你跑\Hash::check了吗?
  • 在您的 LoginController 检查 username() 函数。它返回username 还是email?由于您使用电子邮件进行验证,因此返回值必须是电子邮件。
  • 因为我昨天使用了密码并且根本没有更改它@MalkhaziDartsmelidze

标签: mysql laravel laravel-5 laravel-6 laravel-6.2


【解决方案1】:

试试这个bcrypt

public function setPasswordAttribute($password)
{
  $this->attributes['password'] = bcrypt($password);
}

【讨论】:

  • Laravel 提供了一个自动创建密码哈希的身份验证框架。出于某种原因,它还包括Hash::make()。即使没有,PHP 也提供了password_hashpassword_verify。很少需要直接使用像bcrypt 这样的函数,当然在这种情况下也不需要。
猜你喜欢
  • 2018-06-24
  • 2017-05-14
  • 1970-01-01
  • 2015-06-09
  • 1970-01-01
  • 2020-05-24
  • 1970-01-01
  • 2022-10-04
  • 2016-06-27
相关资源
最近更新 更多