More error handling for login and registration