Fix login to recognize errors correctly