Fixed error handling for login