prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Ensure that dummy users (i.e. old indexers) can't log in.
  Currently, on NewCantus we have created dummy users for people who had an Indexer object but no User account on OldCantus. These dummy users have randomly generated email addresses and no passwords, the rationale being that a user with no password will not be able to log in.
  
  A comment on [this stackoverflow topic](https://stackoverflow.com/questions/35690022/django-create-new-user-without-password) suggests that this is not strictly the case. It would probably be safer to set these dummy users to have [has_useable_password = False](https://docs.djangoproject.com/en/4.2/ref/contrib/auth/#django.contrib.auth.models.User.has_usable_password) if it is not already set up this way.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `django/cantusdb_project/main_app/management/commands/sync_indexers.py`
  Content:
  ```
  1 from django.core.management.base import BaseCommand
  2 from django.contrib.auth import get_user_model
  3 import requests, json
  4 from faker import Faker
  5 
  6 INDEXER_ID_FILE = "indexer_list.txt"
  7 
  8 
  9 def get_id_list(file_path):
  10     indexer_list = []
  11     file = open(file_path, "r")
  12     for line in file:
  13         line = line.strip("\n")
  14         indexer_list.append(line)
  15     file.close()
  16     return indexer_list
  17 
  18 
  19 def get_new_indexer(indexer_id):
  20     # use json-export to get indexer information
  21     url = f"http://cantus.uwaterloo.ca/json-node/{indexer_id}"
  22     response = requests.get(url)
  23     json_response = json.loads(response.content)
  24     if json_response["field_first_name"]:
  25         first_name = json_response["field_first_name"]["und"][0]["value"]
  26     else:
  27         first_name = None
  28     if json_response["field_family_name"]:
  29         family_name = json_response["field_family_name"]["und"][0]["value"]
  30     else:
  31         family_name = None
  32     if json_response["field_indexer_institution"]:
  33         institution = json_response["field_indexer_institution"]["und"][0]["value"]
  34     else:
  35         institution = None
  36     if json_response["field_indexer_city"]:
  37         city = json_response["field_indexer_city"]["und"][0]["value"]
  38     else:
  39         city = None
  40     if json_response["field_indexer_country"]:
  41         country = json_response["field_indexer_country"]["und"][0]["value"]
  42     else:
  43         country = None
  44 
  45     # check whether the current indexer has a user entry of the same name
  46     indexer_full_name = f"{first_name} {family_name}"
  47     print(f"{indexer_id} {indexer_full_name}")
  48     homonymous_users = get_user_model().objects.filter(
  49         full_name__iexact=indexer_full_name
  50     )
  51     # if the indexer also exists as a user
  52     if homonymous_users:
  53         assert homonymous_users.count() == 1
  54         homonymous_user = homonymous_users.get()
  55         print(f"homonymous: {homonymous_user.full_name}")
  56         # keep the user as it is (merge the indexer into existing user)
  57         # and store the ID of its indexer object
  58         homonymous_user.old_indexer_id = indexer_id
  59         homonymous_user.is_indexer = True
  60         homonymous_user.save()
  61     # if the indexer doesn't exist as a user
  62     else:
  63         faker = Faker()
  64         # create a new user with the indexer information
  65         get_user_model().objects.create(
  66             institution=institution,
  67             city=city,
  68             country=country,
  69             full_name=indexer_full_name,
  70             # assign random email to dummy users
  71             email=f"{faker.lexify('????????')}@fakeemail.com",
  72             # leave the password empty for dummy users
  73             # the password can't be empty in login form, so they can't log in
  74             password="",
  75             old_indexer_id=indexer_id,
  76             is_indexer=True,
  77         )
  78 
  79 
  80 class Command(BaseCommand):
  81     def add_arguments(self, parser):
  82         pass
  83 
  84     def handle(self, *args, **options):
  85         indexer_list = get_id_list(INDEXER_ID_FILE)
  86         for id in indexer_list:
  87             get_new_indexer(id)
  88
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/django/cantusdb_project/main_app/management/commands/sync_indexers.py b/django/cantusdb_project/main_app/management/commands/sync_indexers.py
  --- a/django/cantusdb_project/main_app/management/commands/sync_indexers.py
  +++ b/django/cantusdb_project/main_app/management/commands/sync_indexers.py
  @@ -69,12 +69,9 @@
               full_name=indexer_full_name,
               # assign random email to dummy users
               email=f"{faker.lexify('????????')}@fakeemail.com",
  -            # leave the password empty for dummy users
  -            # the password can't be empty in login form, so they can't log in
  -            password="",
               old_indexer_id=indexer_id,
               is_indexer=True,
  -        )
  +        ).set_unusable_password()  # Set unusable password so the user can't log in or access reset password page
   
   
   class Command(BaseCommand):
  
verification_info: {"golden_diff": "diff --git a/django/cantusdb_project/main_app/management/commands/sync_indexers.py b/django/cantusdb_project/main_app/management/commands/sync_indexers.py\n--- a/django/cantusdb_project/main_app/management/commands/sync_indexers.py\n+++ b/django/cantusdb_project/main_app/management/commands/sync_indexers.py\n@@ -69,12 +69,9 @@\n             full_name=indexer_full_name,\n             # assign random email to dummy users\n             email=f\"{faker.lexify('????????')}@fakeemail.com\",\n-            # leave the password empty for dummy users\n-            # the password can't be empty in login form, so they can't log in\n-            password=\"\",\n             old_indexer_id=indexer_id,\n             is_indexer=True,\n-        )\n+        ).set_unusable_password()  # Set unusable password so the user can't log in or access reset password page\n \n \n class Command(BaseCommand):\n", "issue": "Ensure that dummy users (i.e. old indexers) can't log in.\nCurrently, on NewCantus we have created dummy users for people who had an Indexer object but no User account on OldCantus. These dummy users have randomly generated email addresses and no passwords, the rationale being that a user with no password will not be able to log in.\r\n\r\nA comment on [this stackoverflow topic](https://stackoverflow.com/questions/35690022/django-create-new-user-without-password) suggests that this is not strictly the case. It would probably be safer to set these dummy users to have [has_useable_password = False](https://docs.djangoproject.com/en/4.2/ref/contrib/auth/#django.contrib.auth.models.User.has_usable_password) if it is not already set up this way.\n", "before_files": [{"content": "from django.core.management.base import BaseCommand\nfrom django.contrib.auth import get_user_model\nimport requests, json\nfrom faker import Faker\n\nINDEXER_ID_FILE = \"indexer_list.txt\"\n\n\ndef get_id_list(file_path):\n    indexer_list = []\n    file = open(file_path, \"r\")\n    for line in file:\n        line = line.strip(\"\\n\")\n        indexer_list.append(line)\n    file.close()\n    return indexer_list\n\n\ndef get_new_indexer(indexer_id):\n    # use json-export to get indexer information\n    url = f\"http://cantus.uwaterloo.ca/json-node/{indexer_id}\"\n    response = requests.get(url)\n    json_response = json.loads(response.content)\n    if json_response[\"field_first_name\"]:\n        first_name = json_response[\"field_first_name\"][\"und\"][0][\"value\"]\n    else:\n        first_name = None\n    if json_response[\"field_family_name\"]:\n        family_name = json_response[\"field_family_name\"][\"und\"][0][\"value\"]\n    else:\n        family_name = None\n    if json_response[\"field_indexer_institution\"]:\n        institution = json_response[\"field_indexer_institution\"][\"und\"][0][\"value\"]\n    else:\n        institution = None\n    if json_response[\"field_indexer_city\"]:\n        city = json_response[\"field_indexer_city\"][\"und\"][0][\"value\"]\n    else:\n        city = None\n    if json_response[\"field_indexer_country\"]:\n        country = json_response[\"field_indexer_country\"][\"und\"][0][\"value\"]\n    else:\n        country = None\n\n    # check whether the current indexer has a user entry of the same name\n    indexer_full_name = f\"{first_name} {family_name}\"\n    print(f\"{indexer_id} {indexer_full_name}\")\n    homonymous_users = get_user_model().objects.filter(\n        full_name__iexact=indexer_full_name\n    )\n    # if the indexer also exists as a user\n    if homonymous_users:\n        assert homonymous_users.count() == 1\n        homonymous_user = homonymous_users.get()\n        print(f\"homonymous: {homonymous_user.full_name}\")\n        # keep the user as it is (merge the indexer into existing user)\n        # and store the ID of its indexer object\n        homonymous_user.old_indexer_id = indexer_id\n        homonymous_user.is_indexer = True\n        homonymous_user.save()\n    # if the indexer doesn't exist as a user\n    else:\n        faker = Faker()\n        # create a new user with the indexer information\n        get_user_model().objects.create(\n            institution=institution,\n            city=city,\n            country=country,\n            full_name=indexer_full_name,\n            # assign random email to dummy users\n            email=f\"{faker.lexify('????????')}@fakeemail.com\",\n            # leave the password empty for dummy users\n            # the password can't be empty in login form, so they can't log in\n            password=\"\",\n            old_indexer_id=indexer_id,\n            is_indexer=True,\n        )\n\n\nclass Command(BaseCommand):\n    def add_arguments(self, parser):\n        pass\n\n    def handle(self, *args, **options):\n        indexer_list = get_id_list(INDEXER_ID_FILE)\n        for id in indexer_list:\n            get_new_indexer(id)\n", "path": "django/cantusdb_project/main_app/management/commands/sync_indexers.py"}], "after_files": [{"content": "from django.core.management.base import BaseCommand\nfrom django.contrib.auth import get_user_model\nimport requests, json\nfrom faker import Faker\n\nINDEXER_ID_FILE = \"indexer_list.txt\"\n\n\ndef get_id_list(file_path):\n    indexer_list = []\n    file = open(file_path, \"r\")\n    for line in file:\n        line = line.strip(\"\\n\")\n        indexer_list.append(line)\n    file.close()\n    return indexer_list\n\n\ndef get_new_indexer(indexer_id):\n    # use json-export to get indexer information\n    url = f\"http://cantus.uwaterloo.ca/json-node/{indexer_id}\"\n    response = requests.get(url)\n    json_response = json.loads(response.content)\n    if json_response[\"field_first_name\"]:\n        first_name = json_response[\"field_first_name\"][\"und\"][0][\"value\"]\n    else:\n        first_name = None\n    if json_response[\"field_family_name\"]:\n        family_name = json_response[\"field_family_name\"][\"und\"][0][\"value\"]\n    else:\n        family_name = None\n    if json_response[\"field_indexer_institution\"]:\n        institution = json_response[\"field_indexer_institution\"][\"und\"][0][\"value\"]\n    else:\n        institution = None\n    if json_response[\"field_indexer_city\"]:\n        city = json_response[\"field_indexer_city\"][\"und\"][0][\"value\"]\n    else:\n        city = None\n    if json_response[\"field_indexer_country\"]:\n        country = json_response[\"field_indexer_country\"][\"und\"][0][\"value\"]\n    else:\n        country = None\n\n    # check whether the current indexer has a user entry of the same name\n    indexer_full_name = f\"{first_name} {family_name}\"\n    print(f\"{indexer_id} {indexer_full_name}\")\n    homonymous_users = get_user_model().objects.filter(\n        full_name__iexact=indexer_full_name\n    )\n    # if the indexer also exists as a user\n    if homonymous_users:\n        assert homonymous_users.count() == 1\n        homonymous_user = homonymous_users.get()\n        print(f\"homonymous: {homonymous_user.full_name}\")\n        # keep the user as it is (merge the indexer into existing user)\n        # and store the ID of its indexer object\n        homonymous_user.old_indexer_id = indexer_id\n        homonymous_user.is_indexer = True\n        homonymous_user.save()\n    # if the indexer doesn't exist as a user\n    else:\n        faker = Faker()\n        # create a new user with the indexer information\n        get_user_model().objects.create(\n            institution=institution,\n            city=city,\n            country=country,\n            full_name=indexer_full_name,\n            # assign random email to dummy users\n            email=f\"{faker.lexify('????????')}@fakeemail.com\",\n            old_indexer_id=indexer_id,\n            is_indexer=True,\n        ).set_unusable_password()  # Set unusable password so the user can't log in or access reset password page\n\n\nclass Command(BaseCommand):\n    def add_arguments(self, parser):\n        pass\n\n    def handle(self, *args, **options):\n        indexer_list = get_id_list(INDEXER_ID_FILE)\n        for id in indexer_list:\n            get_new_indexer(id)\n", "path": "django/cantusdb_project/main_app/management/commands/sync_indexers.py"}]}