prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  `kinto create-user` doesn't override the password if the user already exists.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `kinto/plugins/accounts/scripts.py`
  Content:
  ```
  1 import logging
  2 import getpass
  3 from pyramid.settings import asbool
  4 
  5 from .utils import hash_password
  6 from .views import AccountIdGenerator
  7 
  8 
  9 logger = logging.getLogger(__name__)
  10 
  11 
  12 def create_user(env, username=None, password=None):
  13     """Administrative command to create a new user."""
  14     registry = env['registry']
  15     settings = registry.settings
  16     readonly_mode = asbool(settings.get('readonly', False))
  17     if readonly_mode:
  18         message = 'Cannot create a user with a readonly server.'
  19         logger.error(message)
  20         return 51
  21 
  22     if 'kinto.plugins.accounts' not in settings['includes']:
  23         message = 'Cannot create a user when the accounts plugin is not installed.'
  24         logger.error(message)
  25         return 52
  26 
  27     try:
  28         validator = AccountIdGenerator()
  29         if username is None:
  30             username = input('Username: ')
  31         while not validator.match(username):
  32             print('{} is not a valid username.')
  33             print('Username should match {0!r}, please try again.'.format(validator.regexp))
  34             username = input('Username: ')
  35 
  36         if password is None:
  37             while True:  # The user didn't entered twice the same password
  38                 password = getpass.getpass('Please enter a password for {}: '.format(username))
  39                 confirm = getpass.getpass('Please confirm the password: '.format(username))
  40 
  41                 if password != confirm:
  42                     print('Sorry, passwords do not match, please try again.')
  43                 else:
  44                     break
  45     except EOFError:
  46         print('User creation aborted')
  47         return 53
  48 
  49     print("Creating user '{}'".format(username))
  50     record = {'id': username, 'password': hash_password(password)}
  51     registry.storage.create(collection_id='account',
  52                             parent_id=username,
  53                             record=record,
  54                             ignore_conflict=True)
  55     registry.permission.add_principal_to_ace('/accounts/{}'.format(username),
  56                                              'write',
  57                                              'account:{}'.format(username))
  58 
  59     return 0
  60
  ```
  --- 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/kinto/plugins/accounts/scripts.py b/kinto/plugins/accounts/scripts.py
  --- a/kinto/plugins/accounts/scripts.py
  +++ b/kinto/plugins/accounts/scripts.py
  @@ -1,5 +1,7 @@
   import logging
   import getpass
  +
  +import transaction as current_transaction
   from pyramid.settings import asbool
   
   from .utils import hash_password
  @@ -56,4 +58,6 @@
                                                'write',
                                                'account:{}'.format(username))
   
  +    current_transaction.commit()
  +
       return 0
  
verification_info: {"golden_diff": "diff --git a/kinto/plugins/accounts/scripts.py b/kinto/plugins/accounts/scripts.py\n--- a/kinto/plugins/accounts/scripts.py\n+++ b/kinto/plugins/accounts/scripts.py\n@@ -1,5 +1,7 @@\n import logging\n import getpass\n+\n+import transaction as current_transaction\n from pyramid.settings import asbool\n \n from .utils import hash_password\n@@ -56,4 +58,6 @@\n                                              'write',\n                                              'account:{}'.format(username))\n \n+    current_transaction.commit()\n+\n     return 0\n", "issue": "`kinto create-user` doesn't override the password if the user already exists.\n\n", "before_files": [{"content": "import logging\nimport getpass\nfrom pyramid.settings import asbool\n\nfrom .utils import hash_password\nfrom .views import AccountIdGenerator\n\n\nlogger = logging.getLogger(__name__)\n\n\ndef create_user(env, username=None, password=None):\n    \"\"\"Administrative command to create a new user.\"\"\"\n    registry = env['registry']\n    settings = registry.settings\n    readonly_mode = asbool(settings.get('readonly', False))\n    if readonly_mode:\n        message = 'Cannot create a user with a readonly server.'\n        logger.error(message)\n        return 51\n\n    if 'kinto.plugins.accounts' not in settings['includes']:\n        message = 'Cannot create a user when the accounts plugin is not installed.'\n        logger.error(message)\n        return 52\n\n    try:\n        validator = AccountIdGenerator()\n        if username is None:\n            username = input('Username: ')\n        while not validator.match(username):\n            print('{} is not a valid username.')\n            print('Username should match {0!r}, please try again.'.format(validator.regexp))\n            username = input('Username: ')\n\n        if password is None:\n            while True:  # The user didn't entered twice the same password\n                password = getpass.getpass('Please enter a password for {}: '.format(username))\n                confirm = getpass.getpass('Please confirm the password: '.format(username))\n\n                if password != confirm:\n                    print('Sorry, passwords do not match, please try again.')\n                else:\n                    break\n    except EOFError:\n        print('User creation aborted')\n        return 53\n\n    print(\"Creating user '{}'\".format(username))\n    record = {'id': username, 'password': hash_password(password)}\n    registry.storage.create(collection_id='account',\n                            parent_id=username,\n                            record=record,\n                            ignore_conflict=True)\n    registry.permission.add_principal_to_ace('/accounts/{}'.format(username),\n                                             'write',\n                                             'account:{}'.format(username))\n\n    return 0\n", "path": "kinto/plugins/accounts/scripts.py"}], "after_files": [{"content": "import logging\nimport getpass\n\nimport transaction as current_transaction\nfrom pyramid.settings import asbool\n\nfrom .utils import hash_password\nfrom .views import AccountIdGenerator\n\n\nlogger = logging.getLogger(__name__)\n\n\ndef create_user(env, username=None, password=None):\n    \"\"\"Administrative command to create a new user.\"\"\"\n    registry = env['registry']\n    settings = registry.settings\n    readonly_mode = asbool(settings.get('readonly', False))\n    if readonly_mode:\n        message = 'Cannot create a user with a readonly server.'\n        logger.error(message)\n        return 51\n\n    if 'kinto.plugins.accounts' not in settings['includes']:\n        message = 'Cannot create a user when the accounts plugin is not installed.'\n        logger.error(message)\n        return 52\n\n    try:\n        validator = AccountIdGenerator()\n        if username is None:\n            username = input('Username: ')\n        while not validator.match(username):\n            print('{} is not a valid username.')\n            print('Username should match {0!r}, please try again.'.format(validator.regexp))\n            username = input('Username: ')\n\n        if password is None:\n            while True:  # The user didn't entered twice the same password\n                password = getpass.getpass('Please enter a password for {}: '.format(username))\n                confirm = getpass.getpass('Please confirm the password: '.format(username))\n\n                if password != confirm:\n                    print('Sorry, passwords do not match, please try again.')\n                else:\n                    break\n    except EOFError:\n        print('User creation aborted')\n        return 53\n\n    print(\"Creating user '{}'\".format(username))\n    record = {'id': username, 'password': hash_password(password)}\n    registry.storage.create(collection_id='account',\n                            parent_id=username,\n                            record=record,\n                            ignore_conflict=True)\n    registry.permission.add_principal_to_ace('/accounts/{}'.format(username),\n                                             'write',\n                                             'account:{}'.format(username))\n\n    current_transaction.commit()\n\n    return 0\n", "path": "kinto/plugins/accounts/scripts.py"}]}