I inherited an application that I am currently porting to laravel. They already have the database designed and they use different tables for authentication than the defaults for laravel. In the database, they have upper case field names.
The emails are saved in a field called MCP_EMAIL
and the password are saved in a field called MCP_PASSWORD
I have managed to change the registration process and users can register fine. The problem is with login. When you attempt to login, nothing happens. No error messages, no logs, nothing. It just keeps coming back to the login page!
Here is the user class.
<?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;
}
}
And the login controller
<?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';
}
}
What am I missing? Why can't I see any error messages?
Update
I was doing everything right. Besides doing everything above, you need to change the name of the input in 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>