synapse_admin_api/users/reset_password/
v1.rs

1//! [POST /_synapse/admin/v1/reset_password/:user_id](https://github.com/matrix-org/synapse/blob/master/docs/admin_api/user_admin_api.rst#reset-password)
2
3use ruma::{
4    api::{metadata, request, response, Metadata},
5    OwnedUserId,
6};
7
8const METADATA: Metadata = metadata! {
9    method: POST,
10    rate_limited: false,
11    authentication: AccessToken,
12    history: {
13        unstable => "/_synapse/admin/v1/reset_password/:user_id",
14    }
15};
16
17#[request]
18pub struct Request {
19    /// user ID of the account to reset the password
20    #[ruma_api(path)]
21    pub user_id: OwnedUserId,
22
23    /// new password
24    pub new_password: String,
25
26    /// Logout all devices of the user, so it necessary to login with the new password again.
27    /// Defaults to true.
28    #[serde(default = "ruma::serde::default_true")]
29    pub logout_devices: bool,
30}
31
32#[derive(Default)]
33#[response]
34pub struct Response {}
35
36impl Request {
37    /// Creates an `Request` with the given user ID and the new password.
38    pub fn new(user_id: OwnedUserId, new_password: String) -> Self {
39        Self { user_id, new_password, logout_devices: true }
40    }
41}
42
43impl Response {
44    /// Creates an empty `Response`.
45    pub fn new() -> Self {
46        Self {}
47    }
48}