add password argument to reset-password admin cmd

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
admin@dimensionproject.net 2024-12-18 20:46:01 -05:00 committed by strawberry
parent 60a952508e
commit 802395bdb7
No known key found for this signature in database
2 changed files with 8 additions and 2 deletions

View file

@ -242,7 +242,11 @@ pub(super) async fn deactivate(
}
#[admin_command]
pub(super) async fn reset_password(&self, username: String) -> Result<RoomMessageEventContent> {
pub(super) async fn reset_password(
&self,
username: String,
password: Option<String>,
) -> Result<RoomMessageEventContent> {
let user_id = parse_local_user_id(self.services, &username)?;
if user_id == self.services.globals.server_user {
@ -252,7 +256,7 @@ pub(super) async fn reset_password(&self, username: String) -> Result<RoomMessag
));
}
let new_password = utils::random_string(AUTO_GEN_PASSWORD_LENGTH);
let new_password = password.unwrap_or_else(|| utils::random_string(AUTO_GEN_PASSWORD_LENGTH));
match self
.services