adds authorization logic to rebuildIndex() function