add password argument to reset-password admin cmd
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
60a952508e
commit
802395bdb7
2 changed files with 8 additions and 2 deletions
|
@ -242,7 +242,11 @@ pub(super) async fn deactivate(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[admin_command]
|
#[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)?;
|
let user_id = parse_local_user_id(self.services, &username)?;
|
||||||
|
|
||||||
if user_id == self.services.globals.server_user {
|
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
|
match self
|
||||||
.services
|
.services
|
||||||
|
|
|
@ -22,6 +22,8 @@ pub(super) enum UserCommand {
|
||||||
ResetPassword {
|
ResetPassword {
|
||||||
/// Username of the user for whom the password should be reset
|
/// Username of the user for whom the password should be reset
|
||||||
username: String,
|
username: String,
|
||||||
|
/// New password for the user, if unspecified one is generated
|
||||||
|
password: Option<String>,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// - Deactivate a user
|
/// - Deactivate a user
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue