我继承了一个目前正在移植到laravel的应用程序。他们已经设计了数据库,并且他们使用不同的表进行身份验证,而不是使用laravel的默认表。在数据库中,它们具有大写的字段名称。
电子邮件保存在名为MCP_EMAIL的字段中,密码保存在名为MCP_PASSWORD的字段中
我已经设法改变了注册过程,用户可以很好地注册。问题出在登录上。当您尝试登录时,什么也没有发生。没有错误消息,没有日志,什么都没有。它会一直返回到登录页面!
下面是user类。
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
protected $table = "user_profiles";
protected $primaryKey ="MCP_ID";
protected $rememberTokenName = 'MCP_REMEMBER_TOKEN';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'MCP_DISPLAY_NAME', 'MCP_EMAIL', 'MCP_PASSWORD',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
const CREATED_AT = "ADDED";
const UPDATED_AT = "MODIFIED";
public function getAuthPassword(){
return $this->MCP_PASSWORD;
}
//seems to be a repetition of protected$rememberTokenName
public function getRememberTokenName()
{
return $this->MCP_REMEMBER_TOKEN;
}
}和登录控制器
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Facade\Auth;
use Log;
class LoginController extends Controller
{
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
public function username(){
return 'MCP_EMAIL';
}
}我遗漏了什么?为什么我看不到任何错误消息?
更新
我做的一切都是对的。除了执行上述操作外,还需要在login.blade.php中更改输入的名称
<div class="form-group{{ $errors->has('MCP_EMAIL') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="MCP_EMAIL" type="email" class="form-control" name="MCP_EMAIL" value="{{ old('MCP_EMAIL') }}" required autofocus>
@if ($errors->has('MCP_EMAIL'))
<span class="help-block">
<strong>{{ $errors->first('MCP_EMAIL') }}</strong>
</span>
@endif
</div>
</div>发布于 2017-08-31 16:21:07
您是否知道L5.4附带了预先构建的身份验证,为了提供一种快速搭建您需要运行php artisan auth:make的方法,我敢肯定您需要在AuthenticatesUsers特征中增加一些函数,除非数据库列。请查看此AuthenticatesUsers
在不使用身份验证脚手架的情况下:
1)不需要从LoginController中删除AuthenticatesUsers
2)尝试根据本节Manually Authenticating Users实现您的LoginController
https://stackoverflow.com/questions/45976081
复制相似问题