I seem to have found a solution, I added an authentication filter at line 1403:
if($boolRestoreBlog) restore_current_blog();
add_filter(‘authenticate’,’wp_authenticate_username_password’,20,3);
return $userData;
At least now everything seems to work ok also when ‘Automatically Register Authenticated Users?’ is set to Yes.
I hope there are no security flaws I have made by doing this? 8) …