mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
don't pass a requester if we don't have one to set_displayname
This commit is contained in:
parent
fb47ce3e6a
commit
b3e346f40c
@ -207,12 +207,12 @@ class ProfileHandler(BaseHandler):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def set_displayname(self, target_user, requester, new_displayname, by_admin=False):
|
def set_displayname(self, target_user, requester, new_displayname, by_admin=False):
|
||||||
"""target_user is the user whose displayname is to be changed;
|
"""target_user is the UserID whose displayname is to be changed;
|
||||||
requester is the user attempting to make this change."""
|
requester is the authenticated user attempting to make this change."""
|
||||||
if not self.hs.is_mine(target_user):
|
if not self.hs.is_mine(target_user):
|
||||||
raise SynapseError(400, "User is not hosted on this Home Server")
|
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")
|
raise AuthError(400, "Cannot set another user's displayname")
|
||||||
|
|
||||||
if not by_admin and self.hs.config.disable_set_displayname:
|
if not by_admin and self.hs.config.disable_set_displayname:
|
||||||
@ -239,6 +239,7 @@ class ProfileHandler(BaseHandler):
|
|||||||
target_user.to_string(), profile
|
target_user.to_string(), profile
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if requester:
|
||||||
yield self._update_join_states(requester, target_user)
|
yield self._update_join_states(requester, target_user)
|
||||||
|
|
||||||
# start a profile replication push
|
# start a profile replication push
|
||||||
|
@ -178,7 +178,7 @@ class RegistrationHandler(BaseHandler):
|
|||||||
|
|
||||||
if display_name:
|
if display_name:
|
||||||
yield self.profile_handler.set_displayname(
|
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:
|
if self.hs.config.user_directory_search_all_users:
|
||||||
@ -208,7 +208,7 @@ class RegistrationHandler(BaseHandler):
|
|||||||
)
|
)
|
||||||
|
|
||||||
yield self.profile_handler.set_displayname(
|
yield self.profile_handler.set_displayname(
|
||||||
user, user, user.localpart, by_admin=True,
|
user, None, user.localpart, by_admin=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
except SynapseError:
|
except SynapseError:
|
||||||
@ -257,7 +257,7 @@ class RegistrationHandler(BaseHandler):
|
|||||||
)
|
)
|
||||||
|
|
||||||
yield self.profile_handler.set_displayname(
|
yield self.profile_handler.set_displayname(
|
||||||
user, user, user.localpart, by_admin=True,
|
user, None, user.localpart, by_admin=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
defer.returnValue(user_id)
|
defer.returnValue(user_id)
|
||||||
@ -308,7 +308,7 @@ class RegistrationHandler(BaseHandler):
|
|||||||
)
|
)
|
||||||
|
|
||||||
yield self.profile_handler.set_displayname(
|
yield self.profile_handler.set_displayname(
|
||||||
user, user, user.localpart, by_admin=True,
|
user, None, user.localpart, by_admin=True,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
yield self.store.add_access_token_to_user(user_id, token)
|
yield self.store.add_access_token_to_user(user_id, token)
|
||||||
@ -466,7 +466,7 @@ class RegistrationHandler(BaseHandler):
|
|||||||
)
|
)
|
||||||
if displayname is not None:
|
if displayname is not None:
|
||||||
yield self.profile_handler.set_displayname(
|
yield self.profile_handler.set_displayname(
|
||||||
user, user, displayname, by_admin=True,
|
user, None, displayname, by_admin=True,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
yield self._auth_handler.delete_access_tokens_for_user(user_id)
|
yield self._auth_handler.delete_access_tokens_for_user(user_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user