summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2016-07-08 17:02:06 +0100
committerGitHub <noreply@github.com>2016-07-08 17:02:06 +0100
commit10f4856b0cdba6c587117c1c5dbad1281a1b0470 (patch)
tree0dcf8daf67457a0c6b03d81a93f6060344e99750 /synapse
parentMerge branch 'master' of github.com:matrix-org/synapse into develop (diff)
parentAdd a comment explaining allow_none (diff)
downloadsynapse-10f4856b0cdba6c587117c1c5dbad1281a1b0470.tar.xz
Merge pull request #914 from matrix-org/markjh/upgrade
Ensure that the guest user is in the database when upgrading accounts
Diffstat (limited to '')
-rw-r--r--synapse/storage/registration.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py
index 0a68341494..d957a629dc 100644
--- a/synapse/storage/registration.py
+++ b/synapse/storage/registration.py
@@ -127,11 +127,26 @@ class RegistrationStore(SQLBaseStore):
 
         try:
             if was_guest:
+                # Ensure that the guest user actually exists
+                # ``allow_none=False`` makes this raise an exception
+                # if the row isn't in the database.
+                self._simple_select_one_txn(
+                    txn,
+                    "users",
+                    keyvalues={
+                        "name": user_id,
+                        "is_guest": 1,
+                    },
+                    retcols=("name",),
+                    allow_none=False,
+                )
+
                 self._simple_update_one_txn(
                     txn,
                     "users",
                     keyvalues={
                         "name": user_id,
+                        "is_guest": 1,
                     },
                     updatevalues={
                         "password_hash": password_hash,