Added logic to check permission before performing a lifecycle action