mirror of
https://github.com/mii443/vrchatapi-rust.git
synced 2025-08-22 15:45:35 +00:00
Add 2fa
This commit is contained in:
@ -5,8 +5,11 @@ async fn main() {
|
||||
let mut config = apis::configuration::Configuration::default();
|
||||
config.basic_auth = Some((String::from("username"), Some(String::from("password"))));
|
||||
|
||||
let me = apis::authentication_api::get_current_user(&config).await.unwrap();
|
||||
println!("Username: {}", me.username.unwrap());
|
||||
|
||||
match apis::authentication_api::get_current_user(&config).await.unwrap() {
|
||||
vrchatapi::models::EitherUserOrTwoFactor::CurrentUser(me) => println!("Username: {}", me.username.unwrap()),
|
||||
vrchatapi::models::EitherUserOrTwoFactor::RequiresTwoFactorAuth(requires_auth) => println!("The Username requires Auth: {:?}", requires_auth.requires_two_factor_auth)
|
||||
}
|
||||
|
||||
let online = apis::system_api::get_current_online_users(&config).await.unwrap();
|
||||
println!("Current Online Users: {}", online);
|
||||
|
@ -55,6 +55,10 @@ cat patches/InviteMessageType-Display.rs >> src/models/invite_message_type.rs
|
||||
# }
|
||||
# }
|
||||
sed -z -i 's/impl ToString for InviteMessageType {\n[ a-zA-Z_\(\)&-\>{\n:=",]*}\n }\n}//g' src/models/invite_message_type.rs
|
||||
# https://github.com/vrchatapi/specification/issues/241
|
||||
cat patches/2FA_Current_User.rs >> src/models/current_user.rs
|
||||
sed -i 's/pub use self::current_user::CurrentUser;/pub use self::current_user::{EitherUserOrTwoFactor, CurrentUser};/g' src/models/mod.rs
|
||||
sed -i 's/Result<crate::models::CurrentUser, Error<GetCurrentUserError>>/Result<crate::models::EitherUserOrTwoFactor, Error<GetCurrentUserError>>/g' src/apis/authentication_api.rs
|
||||
|
||||
|
||||
cargo build
|
||||
|
12
patches/2FA_Current_User.rs
Normal file
12
patches/2FA_Current_User.rs
Normal file
@ -0,0 +1,12 @@
|
||||
#[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<String>
|
||||
}
|
Reference in New Issue
Block a user