【发布时间】:2017-08-31 07:50:09
【问题描述】:
我继承了我目前正在移植到 laravel 的应用程序。他们已经设计了数据库,并且他们使用与 laravel 的默认设置不同的表进行身份验证。在数据库中,它们具有大写的字段名称。
电子邮件保存在名为MCP_EMAIL 的字段中,密码保存在名为MCP_PASSWORD 的字段中
我已设法更改注册流程,用户可以正常注册。 问题在于登录。当您尝试登录时,没有任何反应。没有错误消息,没有日志,什么都没有。它只是不断回到登录页面!
这是用户类。
<?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>
【问题讨论】:
标签: laravel laravel-5 laravel-5.4