feature/sdk-workflows
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 | login::{AccountStatus, LoginParams, UserParam}, |
| 6 | }, |
| 7 | smbcloud_network::{environment::Environment, network::request_login}, |
| 8 | smbcloud_networking::{ |
| 9 | constants::{PATH_USERS_SIGN_IN, SMB_USER_AGENT}, |
| 10 | smb_base_url_builder, |
| 11 | smb_client::SmbClient, |
| 12 | }, |
| 13 | }; |
| 14 | |
| 15 | pub async fn login( |
| 16 | env: Environment, |
| 17 | client: (&SmbClient, &str), |
| 18 | username: String, |
| 19 | password: String, |
| 20 | ) -> Result<AccountStatus, ErrorResponse> { |
| 21 | let login_params = LoginParams { |
| 22 | user: UserParam { |
| 23 | email: username, |
| 24 | password, |
| 25 | }, |
| 26 | }; |
| 27 | let builder = Client::new() |
| 28 | .post(build_smb_login_url(env, client)) |
| 29 | .json(&login_params) |
| 30 | .header("User-agent", SMB_USER_AGENT); |
| 31 | request_login(builder).await |
| 32 | } |
| 33 | |
| 34 | pub(crate) fn build_smb_login_url(env: Environment, client: (&SmbClient, &str)) -> String { |
| 35 | let mut url_builder = smb_base_url_builder(env, client); |
| 36 | url_builder.add_route(PATH_USERS_SIGN_IN); |
| 37 | url_builder.build() |
| 38 | } |