From b02a342750f84ffebb793aa5d3c80780684dd147 Mon Sep 17 00:00:00 2001
From: Kegan Dougal <kegan@matrix.org>
Date: Tue, 20 Oct 2015 11:07:50 +0100
Subject: [PATCH] Don't 500 when the email doesn't map to a valid user ID.

---
 synapse/rest/client/v1/login.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/synapse/rest/client/v1/login.py b/synapse/rest/client/v1/login.py
index dacc416055..b2e4cb8eaa 100644
--- a/synapse/rest/client/v1/login.py
+++ b/synapse/rest/client/v1/login.py
@@ -101,6 +101,10 @@ class LoginRestServlet(ClientV1RestServlet):
             user_id = yield self.hs.get_datastore().get_user_id_by_threepid(
                 login_submission['medium'], login_submission['address']
             )
+            if not user_id:
+                raise LoginError(
+                    401, "Unrecognised address", errcode=Codes.UNAUTHORIZED
+                )
         else:
             user_id = login_submission['user']
 
-- 
GitLab