fix(rooms): prevent removing admin room alias
Only the server user can now remove the #admins alias, matching the existing check for setting the alias. This prevents users from accidentally breaking the admin room functionality. fixes #1408
This commit is contained in:
parent
22a47d1e59
commit
80c9bb4796
1 changed files with 6 additions and 0 deletions
|
|
@ -94,6 +94,12 @@ impl Service {
|
|||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub async fn remove_alias(&self, alias: &RoomAliasId, user_id: &UserId) -> Result<()> {
|
||||
if alias == self.services.globals.admin_alias
|
||||
&& user_id != self.services.globals.server_user
|
||||
{
|
||||
return Err!(Request(Forbidden("Only the server user can remove this alias")));
|
||||
}
|
||||
|
||||
if !self.user_can_remove_alias(alias, user_id).await? {
|
||||
return Err!(Request(Forbidden("User is not permitted to remove this alias.")));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue