From d1b7f8d447ca839e729935c322405a49c2cc367a Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 6 Sep 2019 13:43:01 +0100 Subject: [PATCH 1/5] Ensure the sid parameter is passed to try_unbind_threepid --- synapse/handlers/identity.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/synapse/handlers/identity.py b/synapse/handlers/identity.py index 71b5a8739243..013f55ae016e 100644 --- a/synapse/handlers/identity.py +++ b/synapse/handlers/identity.py @@ -151,12 +151,18 @@ def bind_threepid(self, creds, mxid, use_v2=True): creds ) + sid = creds.get("sid") + if not sid: + raise SynapseError( + 400, "No sid in creds", errcode=Codes.MISSING_PARAM + ) + # If an id_access_token is not supplied, force usage of v1 if id_access_token is None: use_v2 = False # Decide which API endpoint URLs to use - bind_data = {"sid": creds["sid"], "client_secret": client_secret, "mxid": mxid} + bind_data = {"sid": sid, "client_secret": client_secret, "mxid": mxid} if use_v2: bind_url = "https://%s/_matrix/identity/v2/3pid/bind" % (id_server,) bind_data["id_access_token"] = id_access_token From 9fd17858f39a26741bf4a27d654c8b070aa6d31d Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 6 Sep 2019 13:45:48 +0100 Subject: [PATCH 2/5] Add changelog --- changelog.d/5995.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5995.bugfix diff --git a/changelog.d/5995.bugfix b/changelog.d/5995.bugfix new file mode 100644 index 000000000000..e03ab98bc6b2 --- /dev/null +++ b/changelog.d/5995.bugfix @@ -0,0 +1 @@ +Return a M_MISSING_PARAM if `sid` is not provided to `/account/3pid`. \ No newline at end of file From b86186a7acb708c8230c20f6647857cff250d06f Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 6 Sep 2019 13:47:33 +0100 Subject: [PATCH 3/5] lint --- synapse/handlers/identity.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/synapse/handlers/identity.py b/synapse/handlers/identity.py index 013f55ae016e..0c25725510ce 100644 --- a/synapse/handlers/identity.py +++ b/synapse/handlers/identity.py @@ -153,9 +153,7 @@ def bind_threepid(self, creds, mxid, use_v2=True): sid = creds.get("sid") if not sid: - raise SynapseError( - 400, "No sid in creds", errcode=Codes.MISSING_PARAM - ) + raise SynapseError(400, "No sid in creds", errcode=Codes.MISSING_PARAM) # If an id_access_token is not supplied, force usage of v1 if id_access_token is None: From 13cbe693d9480dd5b005429eedd729f3ad3916ab Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 6 Sep 2019 13:49:03 +0100 Subject: [PATCH 4/5] Tell user the correct parameter they messed up --- synapse/handlers/identity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/handlers/identity.py b/synapse/handlers/identity.py index 0c25725510ce..93121368d2f9 100644 --- a/synapse/handlers/identity.py +++ b/synapse/handlers/identity.py @@ -153,7 +153,7 @@ def bind_threepid(self, creds, mxid, use_v2=True): sid = creds.get("sid") if not sid: - raise SynapseError(400, "No sid in creds", errcode=Codes.MISSING_PARAM) + raise SynapseError(400, "No sid in three_pid_creds", errcode=Codes.MISSING_PARAM) # If an id_access_token is not supplied, force usage of v1 if id_access_token is None: From d68cd2f27b31ebbcd7f89f13bfb9be14809e7144 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 6 Sep 2019 13:55:35 +0100 Subject: [PATCH 5/5] lint --- synapse/handlers/identity.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/synapse/handlers/identity.py b/synapse/handlers/identity.py index 93121368d2f9..45db1c1c0680 100644 --- a/synapse/handlers/identity.py +++ b/synapse/handlers/identity.py @@ -153,7 +153,9 @@ def bind_threepid(self, creds, mxid, use_v2=True): sid = creds.get("sid") if not sid: - raise SynapseError(400, "No sid in three_pid_creds", errcode=Codes.MISSING_PARAM) + raise SynapseError( + 400, "No sid in three_pid_creds", errcode=Codes.MISSING_PARAM + ) # If an id_access_token is not supplied, force usage of v1 if id_access_token is None: