summary refs log tree commit diff
path: root/synapse/api/auth.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-11-10 10:35:43 +0000
committerErik Johnston <erik@matrix.org>2014-11-10 10:35:43 +0000
commit407d8a5019e8e352261886d6479f45e6144ae5b4 (patch)
treeeea1d0d57e80551911ab3a8ade97b40684d97316 /synapse/api/auth.py
parentTidy up some of the unused sql tables (diff)
downloadsynapse-407d8a5019e8e352261886d6479f45e6144ae5b4.tar.xz
Fix invite auth
Diffstat (limited to 'synapse/api/auth.py')
-rw-r--r--synapse/api/auth.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py
index d4f284bd60..077d1ab0bf 100644
--- a/synapse/api/auth.py
+++ b/synapse/api/auth.py
@@ -128,13 +128,14 @@ class Auth(object):
         key = (RoomMemberEvent.TYPE, event.user_id, )
         caller = event.old_state_events.get(key)
 
-        caller_in_room = caller and caller.membership == "join"
+        caller_in_room = caller and caller.membership == Membership.JOIN
+        caller_invited = caller and caller.membership == Membership.INVITE
 
         # get info about the target
         key = (RoomMemberEvent.TYPE, target_user_id, )
         target = event.old_state_events.get(key)
 
-        target_in_room = target and target.membership == "join"
+        target_in_room = target and target.membership == Membership.JOIN
 
         membership = event.content["membership"]
 
@@ -162,6 +163,7 @@ class Auth(object):
             "is_membership_change_allowed: %s",
             {
                 "caller_in_room": caller_in_room,
+                "caller_invited": caller_invited,
                 "target_in_room": target_in_room,
                 "membership": membership,
                 "join_rule": join_rule,
@@ -189,7 +191,7 @@ class Auth(object):
             elif join_rule == JoinRules.PUBLIC:
                 pass
             elif join_rule == JoinRules.INVITE:
-                if not caller_in_room:
+                if not caller_in_room and not caller_invited:
                     raise AuthError(403, "You are not invited to this room.")
             else:
                 # TODO (erikj): may_join list