Adding authentication logic