Skip to main content

tuwunel_admin/user/
revoke_admin.rs

1use tuwunel_core::{Err, Result};
2
3use crate::{admin_command, utils::parse_local_user_id};
4
5#[admin_command]
6pub(super) async fn revoke_admin(&self, user_id: String) -> Result {
7	let user_id = parse_local_user_id(self.services, &user_id)?;
8
9	if self
10		.sender
11		.is_some_and(|sender| sender == user_id)
12	{
13		return Err!("You may not revoke your own admin privileges.");
14	}
15
16	self.services.admin.revoke_admin(&user_id).await?;
17
18	write!(self, "{user_id} is no longer an admin.").await
19}