Hi,
I finished update from laravel 5.1 to 5.2 and resolved some problems...
Now i try make login, but the Auth verify the password of the 'password' field but in my db the password has another name that is 'senha'.
illuminate/Auth/EloquentUserProvider.php
/**
* Retrieve a user by the given credentials.
*
* @param array $credentials
* @return \Illuminate\Contracts\Auth\Authenticatable|null
*/
public function retrieveByCredentials(array $credentials)
{
if (empty($credentials)) {
return;
}
// First we will add each credential element to the query as a where clause.
// Then we can execute the query and, if we found a user, return it in a
// Eloquent User "model" that will be utilized by the Guard instances.
$query = $this->createModel()->newQuery();
foreach ($credentials as $key => $value) {
**if (! Str::contains($key, 'password'))** {
$query->where($key, $value);
}
}
return $query->first();
}
how you see, the function tried find the string 'password' in the credentials when it should be 'senha'
The same problem with the validateCredentials function in file illuminate/Auth/EloquentUserProvider.php
/**
* Validate a user against the given credentials.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param array $credentials
* @return bool
*/
public function validateCredentials(UserContract $user, array $credentials)
{
$plain = $credentials['password'];
return $this->hasher->check($plain, $user->getAuthPassword());
}
What is the best way to fix this?
The best way is ...
\ Auth :: attempt ( [ 'email' => ' [email protected] ' , 'password' => ' 1234567890 '] ) ;
And in their model authentication :
/ **
* Get the password for the user .
*
* @return String
* /
getAuthPassword public function ( )
{
return $ this->senha;
}
Yeah that's pretty much the best way to do it :)
Closing since it's not actually a bug report.
Dayglor, Personal thanks for this solution! It worked!
Most helpful comment
The best way is ...
\ Auth :: attempt ( [ 'email' => ' [email protected] ' , 'password' => ' 1234567890 '] ) ;And in their model authentication :