public function retrieveByCredentials(array $credentials)
{
// Check for the interface on the Model
if (in_array(CustomKeyAuthenticable::class, class_implements($this->userModel))) {
// Get the field name
$userObj = new $this->userModel();
$field = $userObj->getAuthKeyName();
unset($userObj);
} else {
// Default approach
$field = 'email';
}
$user = app('\\Doctrine\\ORM\\EntityManager')->getRepository($this->userModel)->findOneBy([$field => $credentials['email']]);
return $user;
}