Skip to main content

ironflow_sdk/
auth_methods.rs

1//! Auth-related methods for [`IronflowClient`].
2
3use crate::client::IronflowClient;
4use crate::error::Error;
5
6impl IronflowClient {
7    /// Change the current user's password.
8    ///
9    /// # Errors
10    ///
11    /// Returns an error if the HTTP request fails or the old password is incorrect.
12    ///
13    /// # Examples
14    ///
15    /// ```no_run
16    /// use ironflow_sdk::IronflowClient;
17    ///
18    /// # async fn example() -> Result<(), ironflow_sdk::Error> {
19    /// let client = IronflowClient::new("https://ironflow.example.com", "key");
20    /// client.change_password("old_pass", "new_pass").await?;
21    /// # Ok(())
22    /// # }
23    /// ```
24    pub async fn change_password(
25        &self,
26        old_password: &str,
27        new_password: &str,
28    ) -> Result<(), Error> {
29        let body = serde_json::json!({
30            "old_password": old_password,
31            "new_password": new_password,
32        });
33        self.send_no_content(self.patch("/api/v1/auth/password").json(&body))
34            .await
35    }
36}