Skip to content

Commit

Permalink
fix: only allow the server user to set the admin alias
Browse files Browse the repository at this point in the history
Should make it safer to move the alias if the admin room broke on a public server.

Signed-off-by: strawberry <[email protected]>
  • Loading branch information
Kladki authored and girlbossceo committed Jun 12, 2024
1 parent 8fff7ea commit 556e782
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/service/rooms/alias/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ pub struct Service {
impl Service {
#[tracing::instrument(skip(self))]
pub fn set_alias(&self, alias: &RoomAliasId, room_id: &RoomId, user_id: &UserId) -> Result<()> {
self.db.set_alias(alias, room_id, user_id)
if alias == services().globals.admin_alias && user_id != services().globals.server_user {
Err(Error::BadRequest(
ErrorKind::forbidden(),
"Only the server user can set this alias",
))
} else {
self.db.set_alias(alias, room_id, user_id)
}
}

#[tracing::instrument(skip(self))]
Expand Down

0 comments on commit 556e782

Please sign in to comment.