don't pass a requester if we don't have one to set_displayname

This commit is contained in:
Matthew Hodgson 2018-05-04 01:56:01 +01:00
parent fb47ce3e6a
commit b3e346f40c
2 changed files with 10 additions and 9 deletions

View File

@ -207,12 +207,12 @@ class ProfileHandler(BaseHandler):
@defer.inlineCallbacks
def set_displayname(self, target_user, requester, new_displayname, by_admin=False):
"""target_user is the user whose displayname is to be changed;
requester is the user attempting to make this change."""
"""target_user is the UserID whose displayname is to be changed;
requester is the authenticated user attempting to make this change."""
if not self.hs.is_mine(target_user):
raise SynapseError(400, "User is not hosted on this Home Server")
if not by_admin and target_user != requester.user:
if not by_admin and requester and target_user != requester.user:
raise AuthError(400, "Cannot set another user's displayname")
if not by_admin and self.hs.config.disable_set_displayname:
@ -239,7 +239,8 @@ class ProfileHandler(BaseHandler):
target_user.to_string(), profile
)
yield self._update_join_states(requester, target_user)
if requester:
yield self._update_join_states(requester, target_user)
# start a profile replication push
run_in_background(self._replicate_profiles)

View File

@ -178,7 +178,7 @@ class RegistrationHandler(BaseHandler):
if display_name:
yield self.profile_handler.set_displayname(
user, user, display_name, by_admin=True,
user, None, display_name, by_admin=True,
)
if self.hs.config.user_directory_search_all_users:
@ -208,7 +208,7 @@ class RegistrationHandler(BaseHandler):
)
yield self.profile_handler.set_displayname(
user, user, user.localpart, by_admin=True,
user, None, user.localpart, by_admin=True,
)
except SynapseError:
@ -257,7 +257,7 @@ class RegistrationHandler(BaseHandler):
)
yield self.profile_handler.set_displayname(
user, user, user.localpart, by_admin=True,
user, None, user.localpart, by_admin=True,
)
defer.returnValue(user_id)
@ -308,7 +308,7 @@ class RegistrationHandler(BaseHandler):
)
yield self.profile_handler.set_displayname(
user, user, user.localpart, by_admin=True,
user, None, user.localpart, by_admin=True,
)
except Exception as e:
yield self.store.add_access_token_to_user(user_id, token)
@ -466,7 +466,7 @@ class RegistrationHandler(BaseHandler):
)
if displayname is not None:
yield self.profile_handler.set_displayname(
user, user, displayname, by_admin=True,
user, None, displayname, by_admin=True,
)
else:
yield self._auth_handler.delete_access_tokens_for_user(user_id)