feature/fix-deployment-script
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 | crate::client_credentials::{ClientCredentials, base_url_builder as tenant_base_url_builder}, |
| 3 | reqwest::Client, |
| 4 | smbcloud_model::{ |
| 5 | error_codes::ErrorResponse, |
| 6 | login::{AccountStatus, LoginParams, UserParam}, |
| 7 | }, |
| 8 | smbcloud_network::{environment::Environment, network::request_login}, |
| 9 | }; |
| 10 | |
| 11 | pub async fn login_with_client( |
| 12 | env: Environment, |
| 13 | client: ClientCredentials<'_>, |
| 14 | username: String, |
| 15 | password: String, |
| 16 | ) -> Result<AccountStatus, ErrorResponse> { |
| 17 | let login_params = LoginParams { |
| 18 | user: UserParam { |
| 19 | email: username, |
| 20 | password, |
| 21 | }, |
| 22 | }; |
| 23 | let builder = Client::new() |
| 24 | .post(build_login_url(env, client)) |
| 25 | .json(&login_params) |
| 26 | .header("User-agent", client.app_id); |
| 27 | request_login(builder).await |
| 28 | } |
| 29 | |
| 30 | fn build_login_url(env: Environment, client: ClientCredentials<'_>) -> String { |
| 31 | let mut url_builder = tenant_base_url_builder(env, client); |
| 32 | url_builder.add_route("v1/client/users/sign_in"); |
| 33 | url_builder.build() |
| 34 | } |