I want to change the default auth fields name in Laravel 5.6, it looks like to work for the username but not for the password.
I looked this questions How to change / Custom password field name for Laravel 4 and Laravel 5 user authentication and the Sample data to test
works but not in my login form.
username is useUsername
password is usePassword
On my login form, I tested to kind of data
When I try to log with a user with the password hash in db, I get These credentials do not match our records
.
When I log with a user without password hash in db, I get an issue Undefined index: password
in the vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php-> validateCredentials(UserContract $user, array $credentials)
what I changed in the loginController.php
protected function validateLogin(Request $request)
{
$this->validate($request, [
$this->username() => 'required',
'usePassword' => 'required',
]);
}
public function username()
{
return 'useUsername';
}
protected function credentials(Request $request)
{
return $request->only($this->username(), 'usePassword');
}
In Users.php
protected $table = 't_user';
public function getAuthPassword()
{
return $this->usePassword;
}
I hope you could help me to solve this issue, I don't really understand why I get these different error with hash or not hash and how I could solve it.
MYT.