Don't grant admin if the first registered user is an appservice, fixes #331
This commit is contained in:
@@ -333,7 +333,7 @@ pub(crate) async fn register_route(
|
|||||||
.full_register(Register {
|
.full_register(Register {
|
||||||
user_id: Some(&user_id),
|
user_id: Some(&user_id),
|
||||||
password,
|
password,
|
||||||
appservice_info: body.appservice_info.as_ref(),
|
is_appservice: body.appservice_info.is_some(),
|
||||||
is_guest,
|
is_guest,
|
||||||
grant_first_user_admin: true,
|
grant_first_user_admin: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|||||||
@@ -2,15 +2,13 @@ use futures::FutureExt;
|
|||||||
use ruma::{UserId, events::GlobalAccountDataEventType, push};
|
use ruma::{UserId, events::GlobalAccountDataEventType, push};
|
||||||
use tuwunel_core::{Err, Result, error, implement, info, is_equal_to, warn};
|
use tuwunel_core::{Err, Result, error, implement, info, is_equal_to, warn};
|
||||||
|
|
||||||
use crate::appservice::RegistrationInfo;
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct Register<'a> {
|
pub struct Register<'a> {
|
||||||
pub user_id: Option<&'a UserId>,
|
pub user_id: Option<&'a UserId>,
|
||||||
pub username: Option<&'a str>,
|
pub username: Option<&'a str>,
|
||||||
pub password: Option<&'a str>,
|
pub password: Option<&'a str>,
|
||||||
pub origin: Option<&'a str>,
|
pub origin: Option<&'a str>,
|
||||||
pub appservice_info: Option<&'a RegistrationInfo>,
|
pub is_appservice: bool,
|
||||||
pub is_guest: bool,
|
pub is_guest: bool,
|
||||||
pub grant_first_user_admin: bool,
|
pub grant_first_user_admin: bool,
|
||||||
pub displayname: Option<&'a str>,
|
pub displayname: Option<&'a str>,
|
||||||
@@ -29,7 +27,7 @@ pub async fn full_register(
|
|||||||
user_id,
|
user_id,
|
||||||
password,
|
password,
|
||||||
origin,
|
origin,
|
||||||
appservice_info,
|
is_appservice,
|
||||||
is_guest,
|
is_guest,
|
||||||
grant_first_user_admin,
|
grant_first_user_admin,
|
||||||
displayname,
|
displayname,
|
||||||
@@ -100,6 +98,7 @@ pub async fn full_register(
|
|||||||
// users
|
// users
|
||||||
// Note: the server user is generated first
|
// Note: the server user is generated first
|
||||||
if !is_guest
|
if !is_guest
|
||||||
|
&& !is_appservice
|
||||||
&& grant_first_user_admin
|
&& grant_first_user_admin
|
||||||
&& self.services.config.grant_admin_to_first_user
|
&& self.services.config.grant_admin_to_first_user
|
||||||
&& let Ok(admin_room) = self.services.admin.get_admin_room().await
|
&& let Ok(admin_room) = self.services.admin.get_admin_room().await
|
||||||
@@ -118,9 +117,7 @@ pub async fn full_register(
|
|||||||
warn!("Granting {user_id} admin privileges as the first user");
|
warn!("Granting {user_id} admin privileges as the first user");
|
||||||
}
|
}
|
||||||
|
|
||||||
if appservice_info.is_none()
|
if !is_appservice && (self.services.config.allow_guests_auto_join_rooms || !is_guest) {
|
||||||
&& (self.services.config.allow_guests_auto_join_rooms || !is_guest)
|
|
||||||
{
|
|
||||||
for room in &self.services.server.config.auto_join_rooms {
|
for room in &self.services.server.config.auto_join_rooms {
|
||||||
let Ok(room_id) = self.services.alias.maybe_resolve(room).await else {
|
let Ok(room_id) = self.services.alias.maybe_resolve(room).await else {
|
||||||
error!(
|
error!(
|
||||||
|
|||||||
Reference in New Issue
Block a user