From 7d09ab891528c16f66fc4adebbafb8134c51f484 Mon Sep 17 00:00:00 2001
From: Daniel Wagner-Hall <daniel@matrix.org>
Date: Wed, 13 Jan 2016 13:19:47 +0000
Subject: [PATCH] Require AS users to be registered before use

---
 synapse/api/auth.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/synapse/api/auth.py b/synapse/api/auth.py
index 876869bb7..e36313e2f 100644
--- a/synapse/api/auth.py
+++ b/synapse/api/auth.py
@@ -528,6 +528,11 @@ class Auth(object):
                             403,
                             "Application service cannot masquerade as this user."
                         )
+                    if not (yield self.store.get_user_by_id(user_id)):
+                        raise AuthError(
+                            403,
+                            "Application service has not registered this user"
+                        )
 
                 if not user_id:
                     raise KeyError