From 4fdfa266f814a643ef6a4d1c564e3215d0532bcc Mon Sep 17 00:00:00 2001 From: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> Date: Sun, 21 Jul 2024 02:30:33 +0200 Subject: [PATCH] Apply Changes --- src/apis/authentication_api.rs | 2 +- src/models/current_user.rs | 12 ++++++++++++ src/models/mod.rs | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/apis/authentication_api.rs b/src/apis/authentication_api.rs index 4d08546..682d4d0 100644 --- a/src/apis/authentication_api.rs +++ b/src/apis/authentication_api.rs @@ -147,7 +147,7 @@ pub fn delete_user(configuration: &configuration::Configuration, user_id: &str) } /// This endpoint does the following two operations: 1) Checks if you are already logged in by looking for a valid `auth` cookie. If you are have a valid auth cookie then no additional auth-related actions are taken. If you are **not** logged in then it will log you in with the `Authorization` header and set the `auth` cookie. The `auth` cookie will only be sent once. 2) If logged in, this function will also return the CurrentUser object containing detailed information about the currently logged in user. The auth string after `Authorization: Basic {string}` is a base64-encoded string of the username and password, both individually url-encoded, and then joined with a colon. > base64(urlencode(username):urlencode(password)) **WARNING: Session Limit:** Each authentication with login credentials counts as a separate session, out of which you have a limited amount. Make sure to save and reuse the `auth` cookie if you are often restarting the program. The provided API libraries automatically save cookies during runtime, but does not persist during restart. While it can be fine to use username/password during development, expect in production to very fast run into the rate-limit and be temporarily blocked from making new sessions until older ones expire. The exact number of simultaneous sessions is unknown/undisclosed. -pub fn get_current_user(configuration: &configuration::Configuration, ) -> Result> { +pub fn get_current_user(configuration: &configuration::Configuration, ) -> Result> { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; diff --git a/src/models/current_user.rs b/src/models/current_user.rs index 2c38325..c3b8668 100644 --- a/src/models/current_user.rs +++ b/src/models/current_user.rs @@ -222,3 +222,15 @@ impl CurrentUser { } } +#[derive(Serialize, Deserialize)] +#[serde(untagged)] +pub enum EitherUserOrTwoFactor{ + CurrentUser(CurrentUser), + RequiresTwoFactorAuth(RequiresTwoFactorAuth), +} + +#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)] +pub struct RequiresTwoFactorAuth{ + #[serde(rename = "requiresTwoFactorAuth")] + pub requires_two_factor_auth: Vec +} \ No newline at end of file diff --git a/src/models/mod.rs b/src/models/mod.rs index fb46a5d..7a6c28e 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -45,7 +45,7 @@ pub use self::create_instance_request::CreateInstanceRequest; pub mod create_world_request; pub use self::create_world_request::CreateWorldRequest; pub mod current_user; -pub use self::current_user::CurrentUser; +pub use self::current_user::{EitherUserOrTwoFactor, CurrentUser}; pub mod current_user_presence; pub use self::current_user_presence::CurrentUserPresence; pub mod deployment_group;