summary refs log tree commit diff
path: root/synapse/api
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/api')
-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