feature/ci-ruby-gems
claude/smbcloud-github-app-k9641p
development
feature/apps
feature/build-release
feature/ci-docs
feature/ci-ruby-gems
feature/cicd
feature/completion
feature/dist-nuget
feature/fix-ci-sdk-pypi-rubygem
feature/fix-clippy-on-stable-channel
feature/fix-deployment-script
feature/github-email
feature/gresiq-v1
feature/project-new-structure
feature/rsync-deploy
feature/ruby-runner
feature/sdk-npm
feature/sdk-workflows
feature/smbcloud-cli-release-npm
feature/smbcloud-deploy
feature/wasm
main
release/v0.7.4
| 1 | use { |
| 2 | reqwest::Client, |
| 3 | smbcloud_model::{ |
| 4 | error_codes::ErrorResponse, |
| 5 | forgot::{Param, UserUpdatePassword}, |
| 6 | reset_password_response::ResetPasswordResponse, |
| 7 | }, |
| 8 | smbcloud_network::{environment::Environment, network::request}, |
| 9 | smbcloud_networking::{ |
| 10 | constants::PATH_USERS_PASSWORD, smb_base_url_builder, smb_client::SmbClient, |
| 11 | }, |
| 12 | }; |
| 13 | |
| 14 | pub async fn reset_password( |
| 15 | env: Environment, |
| 16 | client: (&SmbClient, &str), |
| 17 | token: String, |
| 18 | password: String, |
| 19 | ) -> Result<ResetPasswordResponse, ErrorResponse> { |
| 20 | let password_confirmation = password.clone(); |
| 21 | let params = Param { |
| 22 | user: UserUpdatePassword { |
| 23 | reset_password_token: token, |
| 24 | password, |
| 25 | password_confirmation, |
| 26 | }, |
| 27 | }; |
| 28 | |
| 29 | let builder = Client::new() |
| 30 | .put(build_smb_reset_password_url(env, client)) |
| 31 | .json(¶ms) |
| 32 | .header("Accept", "application/json") |
| 33 | .header("Content-Type", "application/x-www-form-urlencoded"); |
| 34 | |
| 35 | request(builder).await |
| 36 | } |
| 37 | |
| 38 | fn build_smb_reset_password_url(env: Environment, client: (&SmbClient, &str)) -> String { |
| 39 | let mut url_builder = smb_base_url_builder(env, client); |
| 40 | url_builder.add_route(PATH_USERS_PASSWORD); |
| 41 | url_builder.build() |
| 42 | } |