Add proper error handling for login phase