mirror of
https://github.com/ViViDboarder/bitwarden_rs_ldap.git
synced 2024-11-24 20:26:27 +00:00
Update to not query invites, but instead use new _Status field
This commit is contained in:
parent
c42bb99536
commit
c06d23b836
@ -9,26 +9,23 @@ use std::time::{Duration, Instant};
|
|||||||
|
|
||||||
const COOKIE_LIFESPAN: Duration = Duration::from_secs(20 * 60);
|
const COOKIE_LIFESPAN: Duration = Duration::from_secs(20 * 60);
|
||||||
|
|
||||||
fn true_val() -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
#[serde(rename = "Email")]
|
#[serde(rename = "Email")]
|
||||||
email: String,
|
email: String,
|
||||||
#[serde(rename = "_Enabled")]
|
#[serde(rename = "_Status")]
|
||||||
#[serde(default = "true_val")]
|
status: i32,
|
||||||
enabled: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl User {
|
impl User {
|
||||||
pub fn get_email(&self) -> String {
|
pub fn get_email(&self) -> String {
|
||||||
self.email.clone()
|
self.email.clone()
|
||||||
}
|
}
|
||||||
pub fn is_enabled(&self) -> bool {
|
|
||||||
self.enabled
|
pub fn is_disabled(&self) -> bool {
|
||||||
|
// HACK: Magic number
|
||||||
|
self.status != 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,18 +155,4 @@ impl Client {
|
|||||||
let all_users: Vec<User> = self.get("/users").json()?;
|
let all_users: Vec<User> = self.get("/users").json()?;
|
||||||
Ok(all_users)
|
Ok(all_users)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get all invited users
|
|
||||||
pub fn invites(&mut self) -> Result<Vec<User>, Box<Error>> {
|
|
||||||
let all_invites: Vec<User> = self.get("/invites").json()?;
|
|
||||||
Ok(all_invites)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get all users and invites
|
|
||||||
pub fn users_and_invites(&mut self) -> Result<Vec<User>, Box<Error>> {
|
|
||||||
let mut all_users = self.users()?;
|
|
||||||
let mut invites = self.invites()?;
|
|
||||||
all_users.append(&mut invites);
|
|
||||||
Ok(all_users)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -41,14 +41,14 @@ fn invite_users(
|
|||||||
|
|
||||||
/// Creates set of email addresses for users that already exist in Bitwarden
|
/// Creates set of email addresses for users that already exist in Bitwarden
|
||||||
fn get_existing_users(client: &mut bw_admin::Client) -> Result<HashSet<String>, Box<Error>> {
|
fn get_existing_users(client: &mut bw_admin::Client) -> Result<HashSet<String>, Box<Error>> {
|
||||||
let all_users = client.users_and_invites()?;
|
let all_users = client.users()?;
|
||||||
let mut user_emails = HashSet::with_capacity(all_users.len());
|
let mut user_emails = HashSet::with_capacity(all_users.len());
|
||||||
for user in all_users {
|
for user in all_users {
|
||||||
user_emails.insert(user.get_email());
|
user_emails.insert(user.get_email());
|
||||||
if user.is_enabled() {
|
if user.is_disabled() {
|
||||||
println!("Existing user or invite found with email: {}", user.get_email());
|
|
||||||
} else {
|
|
||||||
println!("Existing disabled user found with email: {}", user.get_email());
|
println!("Existing disabled user found with email: {}", user.get_email());
|
||||||
|
} else {
|
||||||
|
println!("Existing user or invite found with email: {}", user.get_email());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user