首页 文章

Laravel 5.2身份验证错误

提问于
浏览
3

我的'用户'表:

id,username,email,password,remember_token

使用默认用户模型:

php artisan make:auth

我根据我的数据库进行了一次简单的更新,在模型/控制器和寄存器视图中将“name”更改为“username” .

注册正常,重定向后用户通过身份验证 .

The problem is in user authentication, I get this error: These credentials do not match our records.

默认登录方法():App \ Http \ Controllers \ Auth \ AuthController @ login

public function login(Request $request)
{
    $this->validateLogin($request);

    // If the class is using the ThrottlesLogins trait, we can automatically throttle
    // the login attempts for this application. We'll key this by the username and
    // the IP address of the client making these requests into this application.
    $throttles = $this->isUsingThrottlesLoginsTrait();

    if ($throttles && $lockedOut = $this->hasTooManyLoginAttempts($request)) {
        $this->fireLockoutEvent($request);

        return $this->sendLockoutResponse($request);
    }

    $credentials = $this->getCredentials($request);

    if (Auth::guard($this->getGuard())->attempt($credentials, $request->has('remember'))) {
        return $this->handleUserWasAuthenticated($request, $throttles);
    }

    // If the login attempt was unsuccessful we will increment the number of attempts
    // to login and redirect the user back to the login form. Of course, when this
    // user surpasses their maximum number of attempts they will get locked out.
    if ($throttles && ! $lockedOut) {
        $this->incrementLoginAttempts($request);
    }

    return $this->sendFailedLoginResponse($request);
}

1 回答

  • 0

    Solved: 我只是将密码类型更新为varchar(60) .

    如果您有自定义用户表,请尊重默认架构!

    Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password', 60);
            $table->rememberToken();
            $table->timestamps();
        });
    

相关问题