gpt4 book ai didi

php - Laravel 问题凭证与我们的记录不匹配

转载 作者:行者123 更新时间:2023-12-04 17:45:21 24 4
gpt4 key购买 nike

首先抱歉我的英语不好。

我是 laravel 的新手。我最近遇到了一些身份验证/登录系统的问题,该系统通过命令 make:auth 内置在 laravel 中。

注册过程运行正常,之后它会自动让我登录。但是当我注销并尝试重新登录时,出现此错误:

These credentials do not match our records.

不知道怎么回事!但我试图在谷歌堆栈溢出等方面搜索错误。我找到的解决方案是这样的。 These credentials do not match our records, laravel 5.2但它也没有用。

这是我的代码。

http/Auth/LoginController.php

<?php

namespace App\Http\Controllers\Auth;

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


class LoginController extends Controller
{

use AuthenticatesUsers;


protected $redirectTo = '/home';

public function __construct()
{
$this->middleware('guest')->except('logout');
}


}

这是模型

用户.php

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
use Notifiable;

protected $fillable = [
'user_name', 'email','user_password','user_created_by',
];

protected $hidden = [
'user_password', 'remember_token',
];

protected $primaryKey = 'user_id';

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

这是 View

Views/auth/login.blade.php

@extends('layouts.app')

@section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Login</div>

<div class="panel-body">
<form class="form-horizontal" method="POST" action="{{ route('login') }}">
{{ csrf_field() }}

<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>

<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus>

@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>

<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="col-md-4 control-label">Password</label>

<div class="col-md-6">
<input id="password" type="password" class="form-control" name="password" required>

@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>

<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<div class="checkbox">
<label>
<input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me
</label>
</div>
</div>
</div>

<div class="form-group">
<div class="col-md-8 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Login
</button>

<a class="btn btn-link" href="{{ route('password.request') }}">
Forgot Your Password?
</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

这是用户表

User Table

最佳答案

在 App\Http\Controllers\Auth\LoginController 中:

public function username()
{
return 'user_name';
}

在 App\Http\User 模型中:

public function getAuthPassword()
{
return $this->user_password;
}

关于php - Laravel 问题凭证与我们的记录不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52345538/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com