Tested with Laravel 5.8
<?php
namespace App\Hashers;
use Illuminate\Contracts\Hashing\Hasher;
class Md5Hasher implements Hasher
{
/**
* Get information about the given hashed value.
*
* @param string $hashedValue
* @return array
*/
public function info($hashedValue)
{
return $hashedValue;
}
/**
* Hash the given value.
*
* @param string $value
* @param array $options
* @return string
*/
public function make($value, array $options = [])
{
return hash('md5', $value);
}
/**
* Check the given plain value against a hash.
*
* @param string $value
* @param string $hashedValue
* @param array $options
* @return bool
*/
public function check($value, $hashedValue, array $options = [])
{
return $this->make($value, $options) === $hashedValue;
}
/**
* Check if the given hash has been hashed using the given options.
*
* @param string $hashedValue
* @param array $options
* @return bool
*/
public function needsRehash($hashedValue, array $options = [])
{
return false;
}
}
Open the login controller class file
App\Http\Controllers\Auth\LoginController
And import the hasher class App\Hashers\Md5Hasher
that you had created.
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use App\Hashers\Md5Hasher; // <-------------- import here
class LoginController extends Controller
// (...)
/**
* Attempt to log the user into the application.
*
* @param \Illuminate\Http\Request $request
* @return bool
*/
protected function attemptLogin(Request $request)
{
$provider = $this->guard()->getProvider();
$provider->setHasher(new Md5Hasher);
$this->guard()->setProvider($provider);
return $this->guard()->attempt(
$this->credentials($request), $request->filled('remember')
);
}