better authentication error handling