Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make access_all optional #4812

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/api/core/organizations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,8 @@ struct InviteData {
groups: Vec<String>,
r#type: NumberOrString,
collections: Option<Vec<CollectionData>>,
access_all: Option<bool>,
#[serde(default)]
access_all: bool,
}

#[post("/organizations/<org_id>/users/invite", data = "<data>")]
Expand Down Expand Up @@ -896,7 +897,7 @@ async fn send_invite(org_id: &str, data: Json<InviteData>, headers: AdminHeaders
};

let mut new_user = UserOrganization::new(user.uuid.clone(), String::from(org_id));
let access_all = data.access_all.unwrap_or(false);
let access_all = data.access_all;
new_user.access_all = access_all;
new_user.atype = new_type;
new_user.status = user_org_status;
Expand Down Expand Up @@ -1297,6 +1298,7 @@ struct EditUserData {
r#type: NumberOrString,
collections: Option<Vec<CollectionData>>,
groups: Option<Vec<String>>,
#[serde(default)]
access_all: bool,
}

Expand Down Expand Up @@ -2223,25 +2225,21 @@ async fn get_groups(org_id: &str, _headers: ManagerHeadersLoose, mut conn: DbCon
#[serde(rename_all = "camelCase")]
struct GroupRequest {
name: String,
access_all: Option<bool>,
#[serde(default)]
access_all: bool,
external_id: Option<String>,
collections: Vec<SelectionReadOnly>,
users: Vec<String>,
}

impl GroupRequest {
pub fn to_group(&self, organizations_uuid: &str) -> Group {
Group::new(
String::from(organizations_uuid),
self.name.clone(),
self.access_all.unwrap_or(false),
self.external_id.clone(),
)
Group::new(String::from(organizations_uuid), self.name.clone(), self.access_all, self.external_id.clone())
}

pub fn update_group(&self, mut group: Group) -> Group {
group.name.clone_from(&self.name);
group.access_all = self.access_all.unwrap_or(false);
group.access_all = self.access_all;
// Group Updates do not support changing the external_id
// These input fields are in a disabled state, and can only be updated/added via ldap_import

Expand Down
Loading