Skip to content

Commit

Permalink
add password argument to reset-password admin cmd
Browse files Browse the repository at this point in the history
Signed-off-by: strawberry <[email protected]>
  • Loading branch information
[email protected] authored and girlbossceo committed Dec 19, 2024
1 parent 60a9525 commit 802395b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/admin/user/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/admin/user/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub(super) enum UserCommand {
ResetPassword {
/// Username of the user for whom the password should be reset
username: String,
/// New password for the user, if unspecified one is generated
password: Option<String>,
},

/// - Deactivate a user
Expand Down

0 comments on commit 802395b

Please sign in to comment.